From e790bc6eeea9d696d32e4e0619764ccf65b17f09 Mon Sep 17 00:00:00 2001 From: erik Date: Mon, 20 Feb 2023 16:37:49 +0100 Subject: [PATCH] WIP Tests --- test/test_version_class.py | 78 +++++++++----------------------------- 1 file changed, 17 insertions(+), 61 deletions(-) diff --git a/test/test_version_class.py b/test/test_version_class.py index 5c7b49a..a6782b4 100644 --- a/test/test_version_class.py +++ b/test/test_version_class.py @@ -1,29 +1,36 @@ -from devops_test import Version, ReleaseLevel +from version import Version +from version_repository import VersionRepository +from release_type import ReleaseType from pathlib import Path def test_version(): version = Version([1, 2, 3], False) version.increment(ReleaseLevel.SNAPSHOT) - assert version.get() == "1.2.3-SNAPSHOT" + assert version.get_version_string() == "1.2.3-SNAPSHOT" assert version.version == [1, 2, 3] assert version.is_snapshot + version.increment(ReleaseLevel.BUMP) + assert version.get_version_string() == "1.2.4-SNAPSHOT" + assert version.version == [1, 2, 4] + assert not version.is_snapshot + version.increment(ReleaseLevel.PATCH) - assert version.get() == "1.2.4" + assert version.get_version_string() == "1.2.5" assert version.version == [1, 2, 4] assert not version.is_snapshot version.increment(ReleaseLevel.SNAPSHOT) - assert version.get() == "1.2.4-SNAPSHOT" + assert version.get_version_string() == "1.2.5-SNAPSHOT" version.increment(ReleaseLevel.SNAPSHOT) - assert version.get() == "1.2.4-SNAPSHOT" + assert version.get_version_string() == "1.2.5-SNAPSHOT" version.increment(ReleaseLevel.MINOR) - assert version.get() == "1.3.0" + assert version.get_version_string() == "1.3.0" version.increment(ReleaseLevel.MAJOR) - assert version.get() == "2.0.0" + assert version.get_version_string() == "2.0.0" def test_gradle(tmp_path): @@ -36,60 +43,9 @@ def test_gradle(tmp_path): f.write_text(contents) # test - version = Version.from_file(f) - version.increment(ReleaseLevel.SNAPSHOT) - version.to_file() + version_repo = VersionRepository.get(f) + version = Version.create_release_version(ReleaseLevel.SNAPSHOT) + version_repo.write_file(version.get_version_string) # check assert 'version = "12.4.678-SNAPSHOT"' in f.read_text() - -def test_json(tmp_path): - # init - file_name = 'config.json' - with open(f'test/resources/{file_name}', 'r') as gradle_file: - contents = gradle_file.read() - - f = tmp_path / file_name - f.write_text(contents) - - # test - version = Version.from_file(f) - version.increment(ReleaseLevel.SNAPSHOT) - version.to_file() - - # check - assert '"version": "123.123.456-SNAPSHOT"' in f.read_text() - -def test_clojure(tmp_path): - # init - file_name = 'config.clj' - with open(f'test/resources/{file_name}', 'r') as gradle_file: - contents = gradle_file.read() - - f = tmp_path / file_name - f.write_text(contents) - - # test - version = Version.from_file(f) - version.increment(ReleaseLevel.SNAPSHOT) - version.to_file() - - # check - assert '1.1.3-SNAPSHOT' in f.read_text() - -def test_python(tmp_path): - # init - file_name = 'config.py' - with open(f'test/resources/{file_name}', 'r') as gradle_file: - contents = gradle_file.read() - - f = tmp_path / file_name - f.write_text(contents) - - # test - version = Version.from_file(f) - version.increment(ReleaseLevel.SNAPSHOT) - version.to_file() - - # check - assert '3.1.3-SNAPSHOT' in f.read_text() \ No newline at end of file