TestComposeConfigCmd ensures the compose-config command behaves as expected with a with a basic docker-compose.override.yaml.
(t *testing.T)
| 20 | // TestComposeConfigCmd ensures the compose-config command behaves |
| 21 | // as expected with a with a basic docker-compose.override.yaml. |
| 22 | func TestComposeConfigCmd(t *testing.T) { |
| 23 | // Create a temporary directory and switch to it. |
| 24 | tmpdir := testcommon.CreateTmpDir(t.Name()) |
| 25 | defer testcommon.CleanupDir(tmpdir) |
| 26 | defer testcommon.Chdir(tmpdir)() |
| 27 | |
| 28 | // Create a config |
| 29 | args := []string{ |
| 30 | "config", |
| 31 | "--docroot", ".", |
| 32 | "--project-name", "compose-config", |
| 33 | "--project-type", "php", |
| 34 | } |
| 35 | |
| 36 | _, err := exec.RunCommand(DdevBin, args) |
| 37 | assert.NoError(t, err) |
| 38 | |
| 39 | //nolint: errcheck |
| 40 | defer exec.RunCommand(DdevBin, []string{"remove", "-RO", "compose-config"}) |
| 41 | |
| 42 | // Ensure ddev utility compose-config works as expected |
| 43 | args = []string{"utility", "compose-config"} |
| 44 | out, err := exec.RunCommand(DdevBin, args) |
| 45 | assert.NoError(t, err) |
| 46 | assert.Contains(t, out, "services") |
| 47 | |
| 48 | // Create a docker-compose.override.yaml |
| 49 | overrideFile := filepath.Join(tmpdir, ".ddev", "docker-compose.override.yaml") |
| 50 | err = os.WriteFile(overrideFile, []byte(override), 0644) |
| 51 | assert.NoError(t, err) |
| 52 | |
| 53 | // Ensure ddev utility compose-config includes override values |
| 54 | args = []string{"utility", "compose-config"} |
| 55 | out, err = exec.RunCommand(DdevBin, args) |
| 56 | assert.NoError(t, err) |
| 57 | assert.Contains(t, out, "my_custom: value_here") |
| 58 | } |
nothing calls this directly
no test coverage detected