Skip to content

Commit c9b48dd

Browse files
committed
README: describe how to add a new test case
1 parent 0c38954 commit c9b48dd

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,54 @@ When you're done, you can deactivate the virtual environment:
4242
```bash
4343
deactivate
4444
```
45+
46+
## Add a new case
47+
48+
Each test case simulates a specific Docker Compose merge scenario. Follow these steps to add a new one.
49+
50+
PR are welcome!
51+
52+
### 1. Create a scenario folder
53+
54+
Create a new directory inside the `cases/` folder. The folder name should be descriptive of the test case (e.g., `15-ports-concat`, `17-volume-override`).
55+
56+
> [!NOTE]
57+
> Folders starting with `_` (underscore) are ignored by the test runner.
58+
59+
### 2. Add Compose files
60+
61+
Inside your new folder, create your YAML files:
62+
63+
* `docker-compose.yaml` (Mandatory): This is the base configuration.
64+
* `docker-compose.override.yaml`: The override file (you can name it differently, e.g., prod.yaml).
65+
66+
> [!NOTE]
67+
> If you have multiple override files, they are applied in alphabetical order
68+
> after the base file.
69+
70+
### 3. Generate the expected result (expected.yaml)
71+
72+
Instead of writing the expected result manually, you can generate it using Docker Compose.
73+
74+
Run the following commands in your terminal:
75+
76+
```bash
77+
# 1. Navigate to your new case folder
78+
cd cases/my_new_case
79+
80+
# 2. Generate the canonical config
81+
docker compose -f docker-compose.yaml -f docker-compose.override.yaml config > expected.yaml
82+
```
83+
84+
> [!IMPORTANT]
85+
> Open `expected.yaml` and manually verify that the generated configuration
86+
> matches what you actually expect. This file acts as the source of truth.
87+
88+
### 4. Run the Tests
89+
90+
Go back to the root of the repository and run the tests to ensure everything is
91+
green:
92+
93+
```bash
94+
pytest -v
95+
```

0 commit comments

Comments
 (0)