diff --git a/tests/__init__.py b/tests/__init__.py index c177f1cf..a44c1a5b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -10,7 +10,7 @@ from itertools import product from os import environ from os.path import dirname, join -from subprocess import Popen +from subprocess import Popen, check_output logging.basicConfig(level=logging.DEBUG) @@ -728,6 +728,34 @@ def test_aggregate_permissions(self): ("autoaggregate",), ) + def test_git_version(self): + smallest_dir = join(SCAFFOLDINGS_DIR, "smallest") + if "COMPOSE_PROJECT_NAME" in os.environ: + image_name = f'{os.environ["COMPOSE_PROJECT_NAME"]}_odoo:latest' + else: + image_name = "smallest_odoo:latest" + image_layers = check_output(["docker", "image", "history", image_name]).split( + b"\n" + ) + git_version_layer = [ + layer for layer in image_layers if b"ARG GIT_VERSION=" in layer + ][0] + git_version = [ + c for c in git_version_layer.split(b" ") if c.startswith(b"GIT_VERSION=") + ][0].split(b"=")[1] + expected_git_version = f"git version {git_version.decode('utf-8')}" + + for sub_env in matrix(): + self.compose_test( + smallest_dir, + sub_env, + ( + "bash", + "-c", + f'set -x; test "$(git --version)" == "{expected_git_version}"' + ), + ) + if __name__ == "__main__": unittest.main()