Skip to content

Commit

Permalink
test: k3d just valid github user or github org with create command
Browse files Browse the repository at this point in the history
  • Loading branch information
jairoFernandez committed Oct 22, 2023
1 parent 3655d17 commit 3042f57
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/k3d/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ func mockCommandComplete() *cobra.Command {
return cmd
}

func mockCommandIComplete() *cobra.Command {
func mockCommandIncomplete() *cobra.Command {
cmd := &cobra.Command{}
cmd.Flags().Bool("ci", false, "ci flag")
return cmd
}

func TestRunK3dShouldReturnErrorIfSomeFlagIsNotPresent(t *testing.T) {
cmd := mockCommandIComplete()
cmd := mockCommandIncomplete()
args := []string{"create"}
err := runK3d(cmd, args)

Expand All @@ -38,3 +38,14 @@ func TestRunK3dShouldReturnErrorIfSomeFlagIsNotPresent(t *testing.T) {
t.Errorf("runK3d(%q) returned an error: %v", args, err)
}
}

func TestRunK3dShouldReturnErrorIfSomeFlagAreNotValid(t *testing.T) {
cmd := mockCommandComplete()
args := []string{"create", "--cluster-name", "test", "--cluster-type", "test"}
err := runK3d(cmd, args)

errorExpected := "only one of --github-user or --github-org can be supplied"
if errorExpected != err.Error() {
t.Errorf("runK3d(%q) returned an error: %v", args, err)
}
}

0 comments on commit 3042f57

Please sign in to comment.