Merge "Added unit test for missing config functions"

This commit is contained in:
Zuul 2020-07-27 13:58:01 +00:00 committed by Gerrit Code Review
commit a85165e99b
5 changed files with 18 additions and 3 deletions

View File

@ -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 {

View File

@ -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)
}

View File

@ -0,0 +1 @@
Management configuration 'default' not modified. No new settings.

View File

@ -0,0 +1 @@
No management configurations defined.

View File

@ -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())