Added unit test for missing config functions

* Added more unit tests to increase test coverage

Change-Id: I30592465cc08528145a8f309fe9b8c403824ccf1
This commit is contained in:
Sirajudeen 2020-07-20 17:39:01 -05:00
parent d21c02c87b
commit 404a09356b
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())