TestDebugConfigYamlCmd tests that ddev utility configyaml works
(t *testing.T)
| 10 | |
| 11 | // TestDebugConfigYamlCmd tests that ddev utility configyaml works |
| 12 | func 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) |
nothing calls this directly
no test coverage detected