first try to implement get_version
This commit is contained in:
parent
ac7f5b8dd1
commit
eafa4a4069
2 changed files with 24 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
from enum import Enum
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
import json
|
||||
from .common import (
|
||||
Validateable,
|
||||
Devops,
|
||||
|
@ -45,3 +46,7 @@ class BuildFile(Validateable):
|
|||
case _:
|
||||
result = None
|
||||
return result
|
||||
|
||||
def get_version(self) -> Version:
|
||||
version = json.loads(self.content)["version"]
|
||||
return Version.from_str(version)
|
||||
|
|
|
@ -2,6 +2,7 @@ from pathlib import Path
|
|||
from src.main.python.ddadevops.domain import (
|
||||
BuildFileType,
|
||||
BuildFile,
|
||||
Version,
|
||||
)
|
||||
|
||||
|
||||
|
@ -31,3 +32,21 @@ def test_sould_calculate_build_type():
|
|||
"content"
|
||||
)
|
||||
assert sut.build_file_type() == BuildFileType.JAVA_CLOJURE
|
||||
|
||||
def test_sould_parse_version():
|
||||
sut = BuildFile(
|
||||
Path("./package.js"),
|
||||
"""{
|
||||
"name": "c4k-jira",
|
||||
"description": "Generate c4k yaml for a jira deployment.",
|
||||
"author": "meissa GmbH",
|
||||
"version": "1.1.5-SNAPSHOT",
|
||||
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-jira#readme",
|
||||
"bin": {
|
||||
"c4k-jira": "./c4k-jira.js"
|
||||
},
|
||||
}
|
||||
"""
|
||||
)
|
||||
assert sut.get_version() == Version.from_str("1.1.5-SNAPSHOT")
|
||||
|
||||
|
|
Loading…
Reference in a new issue