forked from kyma-project/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uninstall: adapt to installer changes (kyma-project#152)
* uninstall: adapt to installer changes - Now uninstallation has infinite retries, thus a timeout is mandatory. - Added first unit tests
- Loading branch information
Showing
2 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package uninstall | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
"time" | ||
|
||
"github.com/kyma-project/cli/pkg/kyma/core" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestUninstallFlags ensures that the provided command flags are stored in the options. | ||
func TestUninstallFlags(t *testing.T) { | ||
o := NewOptions(&core.Options{}) | ||
c := NewCmd(o) | ||
c.SetOutput(ioutil.Discard) // not interested in the command's output | ||
|
||
// test default flag values | ||
require.Error(t, c.Execute(), "Command execution should fail") // command fails becuase there is no kyma to uninstall, but it is ok. | ||
require.Equal(t, 30*time.Minute, o.Timeout, "Default uninstall timeout not correct") | ||
|
||
// test passing flags | ||
c.SetArgs([]string{"--timeout=60m0s"}) | ||
|
||
require.Error(t, c.Execute(), "Command execution should fail") | ||
require.Equal(t, 60*time.Minute, o.Timeout, "Default uninstall timeout not correct") | ||
} | ||
|
||
func TestUninstallSubcommands(t *testing.T) { | ||
o := NewOptions(&core.Options{}) | ||
c := NewCmd(o) | ||
c.SetOutput(ioutil.Discard) // not interested in the command's output | ||
|
||
sub := c.Commands() | ||
|
||
require.Equal(t, 0, len(sub), "Number of uninstall subcommands not as expected") | ||
} |