MCPcopy Index your code
hub / github.com/ddev/ddev / TestComposeConfigCmd

Function TestComposeConfigCmd

cmd/ddev/cmd/debug-compose-config_test.go:22–58  ·  view source on GitHub ↗

TestComposeConfigCmd ensures the compose-config command behaves as expected with a with a basic docker-compose.override.yaml.

(t *testing.T)

Source from the content-addressed store, hash-verified

20// TestComposeConfigCmd ensures the compose-config command behaves
21// as expected with a with a basic docker-compose.override.yaml.
22func 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}

Callers

nothing calls this directly

Calls 4

CreateTmpDirFunction · 0.92
CleanupDirFunction · 0.92
ChdirFunction · 0.92
RunCommandFunction · 0.92

Tested by

no test coverage detected