|
1 | 1 | #!/usr/bin/env python
|
2 | 2 |
|
3 | 3 | import json
|
| 4 | +import os |
4 | 5 | import re
|
5 | 6 |
|
6 | 7 | import docker
|
7 | 8 |
|
8 | 9 | client = docker.from_env()
|
9 |
| -images = json.loads(open("tests/data/modules/data.json").read()) |
| 10 | +script_dir = os.path.dirname(os.path.abspath(__file__)) |
| 11 | +with open(f"{script_dir}../data/modules/data.json") as file: |
| 12 | + images = json.load(file) |
10 | 13 |
|
11 |
| -for image in images["images"]: |
12 |
| - regexInstalled = image["regex"] |
13 |
| - for package in image["packages"]: |
14 |
| - command = f"{image['cmd']} {package['name']}" |
15 |
| - output = client.containers.run( |
16 |
| - image["image"], command, entrypoint="", platform=image["platform"], auto_remove=True, detach=False |
17 |
| - ) |
18 |
| - result = re.search(regexInstalled, output.decode("utf-8").strip()) |
19 |
| - assert result, f"{package['name']} not found in {image['image']}, output: {output.decode('utf-8').strip()}" |
20 |
| - assert result.group(2).startswith( |
21 |
| - package["version"] |
22 |
| - ), f"{package['name']} version {package['version']} does not match {result.group(2)}" |
23 |
| - print(image["image"], result.group(1, 2, 3)) |
| 14 | + for image in images["images"]: |
| 15 | + regexInstalled = image["regex"] |
| 16 | + for package in image["packages"]: |
| 17 | + command = f"{image['cmd']} {package['name']}" |
| 18 | + output = client.containers.run( |
| 19 | + image["image"], command, entrypoint="", platform=image["platform"], auto_remove=True, detach=False |
| 20 | + ) |
| 21 | + result = re.search(regexInstalled, output.decode("utf-8").strip()) |
| 22 | + assert result, f"{package['name']} not found in {image['image']}, output: {output.decode('utf-8').strip()}" |
| 23 | + assert result.group(2).startswith( |
| 24 | + package["version"] |
| 25 | + ), f"{package['name']} version {package['version']} does not match {result.group(2)}" |
| 26 | + print(image["image"], result.group(1, 2, 3)) |
0 commit comments