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

Function TestDebugConfigYamlCmd

cmd/ddev/cmd/debug-config-yaml_test.go:12–113  ·  view source on GitHub ↗

TestDebugConfigYamlCmd tests that ddev utility configyaml works

(t *testing.T)

Source from the content-addressed store, hash-verified

10
11// TestDebugConfigYamlCmd tests that ddev utility configyaml works
12func TestDebugConfigYamlCmd(t *testing.T) {
13 // Create a temporary directory and switch to it.
14 tmpdir := testcommon.CreateTmpDir(t.Name())
15 defer testcommon.CleanupDir(tmpdir)
16 defer testcommon.Chdir(tmpdir)()
17
18 // Create a basic config
19 args := []string{
20 "config",
21 "--docroot", ".",
22 "--project-name", "config-yaml-test",
23 "--project-type", "php",
24 }
25
26 _, err := exec.RunCommand(DdevBin, args)
27 require.NoError(t, err)
28
29 t.Cleanup(func() {
30 _, _ = exec.RunCommand(DdevBin, []string{"delete", "-Oy", "config-yaml-test"})
31 })
32
33 // Test basic configyaml output (field-by-field mode)
34 t.Run("basic configyaml output", func(t *testing.T) {
35 out, err := exec.RunCommand(DdevBin, []string{"utility", "configyaml"})
36 require.NoError(t, err)
37 // Note: "These config files were loaded" now goes to stderr, not stdout
38 require.Contains(t, out, "name: config-yaml-test")
39 require.Contains(t, out, "type: php")
40 require.Contains(t, out, "docroot: .")
41 })
42
43 // Test --full-yaml mode
44 t.Run("full-yaml mode", func(t *testing.T) {
45 out, err := exec.RunCommand(DdevBin, []string{"utility", "configyaml", "--full-yaml"})
46 require.NoError(t, err)
47 // Note: "These config files were loaded" now goes to stderr, not stdout
48 require.Contains(t, out, "# Complete processed project configuration:")
49 require.Contains(t, out, "name: config-yaml-test")
50 require.Contains(t, out, "type: php")
51 require.Contains(t, out, "docroot: .")
52 // Should be valid YAML format
53 require.Contains(t, out, "webserver_type:")
54 require.Contains(t, out, "php_version:")
55 })
56
57 // Test --omit-keys functionality in regular mode
58 t.Run("omit-keys in regular mode", func(t *testing.T) {
59 out, err := exec.RunCommand(DdevBin, []string{"utility", "configyaml", "--omit-keys=name,type"})
60 require.NoError(t, err)
61 require.NotContains(t, out, "name: config-yaml-test")
62 require.NotContains(t, out, "type: php")
63 require.Contains(t, out, "docroot: .") // This should still be present
64 })
65
66 // Test --omit-keys functionality in full-yaml mode
67 t.Run("omit-keys in full-yaml mode", func(t *testing.T) {
68 out, err := exec.RunCommand(DdevBin, []string{"utility", "configyaml", "--full-yaml", "--omit-keys=name,type"})
69 require.NoError(t, err)

Callers

nothing calls this directly

Calls 6

CreateTmpDirFunction · 0.92
CleanupDirFunction · 0.92
ChdirFunction · 0.92
RunCommandFunction · 0.92
CleanupMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected