diff --git a/cmd/config/get_management_config_test.go b/cmd/config/get_management_config_test.go index d0aa09ff9..3f1f6f85f 100644 --- a/cmd/config/get_management_config_test.go +++ b/cmd/config/get_management_config_test.go @@ -37,6 +37,9 @@ func TestGetManagementConfigCmd(t *testing.T) { }, }, } + emptySettings := &environment.AirshipCTLSettings{ + Config: &config.Config{}, + } cmdTests := []*testutil.CmdTest{ { @@ -60,6 +63,11 @@ func TestGetManagementConfigCmd(t *testing.T) { CmdLine: config.AirshipDefaultContext, Cmd: cmd.NewGetManagementConfigCommand(settings), }, + { + Name: "get-empty-management-config", + CmdLine: "", + Cmd: cmd.NewGetManagementConfigCommand(emptySettings), + }, } for _, tt := range cmdTests { diff --git a/cmd/config/set_management_configuration_test.go b/cmd/config/set_management_configuration_test.go index d25f78751..369ecfe24 100644 --- a/cmd/config/set_management_configuration_test.go +++ b/cmd/config/set_management_configuration_test.go @@ -84,6 +84,11 @@ func TestConfigSetManagementConfigurationInsecure(t *testing.T) { CmdLine: fmt.Sprintf("%s --insecure=true", config.AirshipDefaultContext), Cmd: cmd.NewSetManagementConfigCommand(settings), }) + testutil.RunTest(t, &testutil.CmdTest{ + Name: "config-cmd-set-management-config-no-change", + CmdLine: fmt.Sprintf("%s --insecure=true", config.AirshipDefaultContext), + Cmd: cmd.NewSetManagementConfigCommand(settings), + }) assert.True(t, settings.Config.ManagementConfiguration[config.AirshipDefaultContext].Insecure) } diff --git a/cmd/config/testdata/TestConfigSetManagementConfigurationInsecureGoldenOutput/config-cmd-set-management-config-no-change.golden b/cmd/config/testdata/TestConfigSetManagementConfigurationInsecureGoldenOutput/config-cmd-set-management-config-no-change.golden new file mode 100644 index 000000000..33d7fd879 --- /dev/null +++ b/cmd/config/testdata/TestConfigSetManagementConfigurationInsecureGoldenOutput/config-cmd-set-management-config-no-change.golden @@ -0,0 +1 @@ +Management configuration 'default' not modified. No new settings. diff --git a/cmd/config/testdata/TestGetManagementConfigCmdGoldenOutput/get-empty-management-config.golden b/cmd/config/testdata/TestGetManagementConfigCmdGoldenOutput/get-empty-management-config.golden new file mode 100644 index 000000000..f9e7753d2 --- /dev/null +++ b/cmd/config/testdata/TestGetManagementConfigCmdGoldenOutput/get-empty-management-config.golden @@ -0,0 +1 @@ +No management configurations defined. diff --git a/pkg/environment/settings_test.go b/pkg/environment/settings_test.go index 3d6adf342..2d7975a10 100644 --- a/pkg/environment/settings_test.go +++ b/pkg/environment/settings_test.go @@ -75,9 +75,9 @@ func TestInitConfig(t *testing.T) { defer os.Unsetenv(config.AirshipKubeConfigEnv) defer os.Unsetenv(config.AirshipPluginPathEnv) - testSettings.InitAirshipConfigPath() - testSettings.InitKubeConfigPath() - environment.InitPluginPath() + testSettings.Create = true + testSettings.InitConfig() + assert.Equal(t, expectedAirshipConfig, testSettings.AirshipConfigPath) assert.Equal(t, expectedKubeConfig, testSettings.KubeConfigPath) assert.Equal(t, expectedPluginPath, environment.PluginPath())