wip: calculate forgejo_release_api_endpoint
This commit is contained in:
parent
2469fd2f5b
commit
5f5743354c
3 changed files with 58 additions and 0 deletions
|
@ -24,6 +24,9 @@ class Release(Validateable):
|
|||
"release_secondary_build_files", []
|
||||
)
|
||||
self.version = version
|
||||
self.release_artifact_server_url = inp.get("release_artifact_server_url")
|
||||
self.release_organisation = inp.get("release_organisation")
|
||||
self.release_repository_name = inp.get("release_repository_name")
|
||||
|
||||
def update_release_type(self, release_type: ReleaseType):
|
||||
self.release_type = release_type
|
||||
|
@ -63,3 +66,8 @@ class Release(Validateable):
|
|||
result = [self.release_primary_build_file]
|
||||
result += self.release_secondary_build_files
|
||||
return result
|
||||
|
||||
def forgejo_release_api_endpoint(self):
|
||||
if self.release_artifact_server_url == None or self.release_organisation == None or self.release_repository_name == None:
|
||||
raise RuntimeError("when doing artifact release, release_artifact_server_url, release_organisation, release_repository_name may not be None.")
|
||||
return f"{self.release_artifact_server_url}/api/v1/repos/{self.release_organisation}/{self.release_repository_name}/releases"
|
||||
|
|
|
@ -53,6 +53,10 @@ def devops_config(overrides: dict) -> dict:
|
|||
"release_current_branch": "my_feature",
|
||||
"release_primary_build_file": "./package.json",
|
||||
"release_secondary_build_file": [],
|
||||
"release_artifacts": [],
|
||||
"release_artifact_server_url": None,
|
||||
"release_organisation": None,
|
||||
"release_repository_name": None,
|
||||
"credentials_mappings": [
|
||||
{
|
||||
"gopass_path": "a/path",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import pytest
|
||||
from pybuilder.core import Project
|
||||
from pathlib import Path
|
||||
from src.main.python.ddadevops.domain import (
|
||||
|
@ -61,3 +62,48 @@ def test_sould_calculate_build_files():
|
|||
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
||||
)
|
||||
assert ["project.clj", "package.json"] == sut.build_files()
|
||||
|
||||
|
||||
def test_should_calculate_forgejo_release_api_endpoint():
|
||||
sut = Release(
|
||||
devops_config(
|
||||
{
|
||||
"release_artifact_server_url": "https://repo.prod.meissa.de",
|
||||
"release_organisation": "meissa",
|
||||
"release_repository_name": "provs",
|
||||
}
|
||||
),
|
||||
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
||||
)
|
||||
assert (
|
||||
"https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases"
|
||||
== sut.forgejo_release_api_endpoint()
|
||||
)
|
||||
|
||||
sut = Release(
|
||||
devops_config(
|
||||
{
|
||||
"release_artifact_server_url": "https://repo.prod.meissa.de/",
|
||||
"release_organisation": "/meissa/",
|
||||
"release_repository_name": "provs",
|
||||
}
|
||||
),
|
||||
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
||||
)
|
||||
assert (
|
||||
"https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases"
|
||||
== sut.forgejo_release_api_endpoint()
|
||||
)
|
||||
|
||||
with pytest.raises(Exception):
|
||||
sut = Release(
|
||||
devops_config(
|
||||
{
|
||||
"release_artifact_server_url": "https://repo.prod.meissa.de",
|
||||
"release_organisation": None,
|
||||
"release_repository_name": "provs",
|
||||
}
|
||||
),
|
||||
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
||||
)
|
||||
sut.forgejo_release_api_endpoint()
|
||||
|
|
Loading…
Reference in a new issue