MCPcopy Create free account
hub / github.com/ddev/ddev / TestGlobalConfigOmitProjectNameDefault

Function TestGlobalConfigOmitProjectNameDefault

cmd/ddev/cmd/config_test.go:1203–1233  ·  view source on GitHub ↗

TestGlobalConfigOmitProjectNameDefault tests the global config flag handling

(t *testing.T)

Source from the content-addressed store, hash-verified

1201
1202// TestGlobalConfigOmitProjectNameDefault tests the global config flag handling
1203func TestGlobalConfigOmitProjectNameDefault(t *testing.T) {
1204 assert := asrt.New(t)
1205
1206 // Create temporary XDG_CONFIG_HOME for isolated testing
1207 tmpXdgConfigHomeDir := testcommon.CopyGlobalDdevDir(t)
1208
1209 t.Cleanup(func() {
1210 testcommon.ResetGlobalDdevDir(t, tmpXdgConfigHomeDir)
1211 })
1212
1213 // Ensure global config exists
1214 globalconfig.EnsureGlobalConfig()
1215
1216 // Test setting to true directly (avoids subprocess environment variable issues)
1217 globalconfig.DdevGlobalConfig.OmitProjectNameByDefault = true
1218 err := globalconfig.WriteGlobalConfig(globalconfig.DdevGlobalConfig)
1219 require.NoError(t, err)
1220
1221 err = globalconfig.ReadGlobalConfig()
1222 require.NoError(t, err)
1223 assert.True(globalconfig.DdevGlobalConfig.OmitProjectNameByDefault)
1224
1225 // Test setting to false
1226 globalconfig.DdevGlobalConfig.OmitProjectNameByDefault = false
1227 err = globalconfig.WriteGlobalConfig(globalconfig.DdevGlobalConfig)
1228 require.NoError(t, err)
1229
1230 err = globalconfig.ReadGlobalConfig()
1231 require.NoError(t, err)
1232 assert.False(globalconfig.DdevGlobalConfig.OmitProjectNameByDefault)
1233}

Callers

nothing calls this directly

Calls 6

CopyGlobalDdevDirFunction · 0.92
ResetGlobalDdevDirFunction · 0.92
EnsureGlobalConfigFunction · 0.92
WriteGlobalConfigFunction · 0.92
ReadGlobalConfigFunction · 0.92
CleanupMethod · 0.80

Tested by

no test coverage detected