Skip to content

Commit

Permalink
[IMP] tests: add a test to verify the git version
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-wtioit committed Jan 19, 2023
1 parent 5972a77 commit fadb9cb
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()

0 comments on commit fadb9cb

Please sign in to comment.