add one more test

This commit is contained in:
Michael Jerger 2023-06-28 08:23:33 +02:00
parent e0239d7f08
commit 9445cf6b5f
3 changed files with 32 additions and 10 deletions

View file

@ -70,15 +70,21 @@ def build_devops(
class BuildFileRepositoryMock: class BuildFileRepositoryMock:
def get(self, path: Path) -> BuildFile: def __init__(self, file_name=None):
return BuildFile( if file_name:
Path("./package.json"), self.file_path = Path(f"./src/test/resources/{file_name}")
""" with open(self.file_path, "r", encoding="utf-8") as input_file:
self.content = input_file.read()
else:
self.file_path = Path("./package.json")
self.content = """
{ {
"version": "1.1.5-SNAPSHOT" "version": "1.1.5-SNAPSHOT"
} }
""", """
)
def get(self, path: Path) -> BuildFile:
return BuildFile(self.file_path, self.content)
def write(self, build_file: BuildFile): def write(self, build_file: BuildFile):
pass pass

View file

@ -101,18 +101,19 @@ from pybuilder.core import init, use_plugin, Author
use_plugin("python.core") use_plugin("python.core")
name = "ddadevops" name = "ddadevops"
version = "1.1.5-dev" version = "1.1.5-dev12"
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
""", """,
) )
assert sut.get_version() == Version.from_str("1.1.5-dev") assert sut.get_version() == Version.from_str("1.1.5-dev12")
sut = BuildFile( sut = BuildFile(
Path("./build.py"), Path("./build.py"),
""" """
version = "1.1.5-dev1" version = "1.1.5-dev12"
""", """,
) )
sut.set_version(Version.from_str("1.1.5-dev1").create_major()) sut.set_version(Version.from_str("1.1.5-dev12").create_major())
assert '\nversion = "2.0.0"\n' == sut.content assert '\nversion = "2.0.0"\n' == sut.content

View file

@ -31,6 +31,21 @@ def test_should_load_build_file():
== sut.initialize(devops_config({})).mixins[MixinType.RELEASE].version == sut.initialize(devops_config({})).mixins[MixinType.RELEASE].version
) )
sut = InitService(
DevopsFactory(),
BuildFileRepositoryMock("build.py"),
CredentialsApiMock({
"server/meissa/grafana-cloud:grafana-cloud-user": "gopass-gfc-user",
"server/meissa/grafana-cloud": "gopass-gfc-password",
}),
EnvironmentApiMock({}),
GitApiMock(),
)
assert (
Version.from_str("4.0.0-dev73")
== sut.initialize(devops_config({})).mixins[MixinType.RELEASE].version
)
def test_should_resolve_passwords(): def test_should_resolve_passwords():
sut = InitService( sut = InitService(