ClickHouse/tests/ci/test_docker.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
2.3 KiB
Python
Raw Normal View History

#!/usr/bin/env python
import unittest
from unittest.mock import patch, MagicMock
from version_helper import get_version_from_string
import docker_server as ds
# di.logging.basicConfig(level=di.logging.INFO)
class TestDockerServer(unittest.TestCase):
def test_gen_tags(self):
2022-04-01 15:53:43 +00:00
version = get_version_from_string("22.2.2.2")
cases = (
2022-04-01 15:53:43 +00:00
("latest", ["latest", "22", "22.2", "22.2.2", "22.2.2.2"]),
("major", ["22", "22.2", "22.2.2", "22.2.2.2"]),
("minor", ["22.2", "22.2.2", "22.2.2.2"]),
("patch", ["22.2.2", "22.2.2.2"]),
("head", ["head"]),
)
for case in cases:
2022-04-01 15:53:43 +00:00
release_type = case[0]
self.assertEqual(case[1], ds.gen_tags(version, release_type))
with self.assertRaises(ValueError):
2022-04-01 15:53:43 +00:00
ds.gen_tags(version, "auto")
@patch("docker_server.get_tagged_versions")
2022-11-10 15:57:01 +00:00
def test_auto_release_type(self, mock_tagged_versions: MagicMock) -> None:
mock_tagged_versions.return_value = [
get_version_from_string("1.1.1.1"),
get_version_from_string("1.2.1.1"),
get_version_from_string("2.1.1.1"),
get_version_from_string("2.2.1.1"),
get_version_from_string("2.2.2.1"),
]
cases_less = (
2022-04-01 15:53:43 +00:00
(get_version_from_string("1.0.1.1"), "minor"),
(get_version_from_string("1.1.2.1"), "minor"),
(get_version_from_string("1.3.1.1"), "major"),
(get_version_from_string("2.1.2.1"), "minor"),
(get_version_from_string("2.2.1.3"), "patch"),
(get_version_from_string("2.2.3.1"), "latest"),
(get_version_from_string("2.3.1.1"), "latest"),
)
for case in cases_less:
release = ds.auto_release_type(case[0], "auto")
self.assertEqual(case[1], release)
cases_equal = (
(get_version_from_string("1.1.1.1"), "minor"),
(get_version_from_string("1.2.1.1"), "major"),
(get_version_from_string("2.1.1.1"), "minor"),
(get_version_from_string("2.2.1.1"), "patch"),
(get_version_from_string("2.2.2.1"), "latest"),
)
for case in cases_equal:
release = ds.auto_release_type(case[0], "auto")
self.assertEqual(case[1], release)