-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: k3d create with incomplete flags
- Loading branch information
1 parent
41117f4
commit 3655d17
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package k3d | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func mockCommandComplete() *cobra.Command { | ||
cmd := &cobra.Command{} | ||
cmd.Flags().Bool("ci", false, "ci flag") | ||
cmd.Flags().String("cluster-name", "default", "cluster-name flag") | ||
cmd.Flags().String("cluster-type", "default", "cluster-type flag") | ||
cmd.Flags().String("github-org", "default", "github-org flag") | ||
cmd.Flags().String("github-user", "default", "github-user flag") | ||
cmd.Flags().String("gitlab-group", "default", "gitlab-group flag") | ||
cmd.Flags().String("git-provider", "default", "git-provider flag") | ||
cmd.Flags().String("git-protocol", "default", "git-protocol flag") | ||
cmd.Flags().String("gitops-template-url", "default", "gitops-template-url flag") | ||
cmd.Flags().String("gitops-template-branch", "default", "gitops-template-branch flag") | ||
cmd.Flags().Bool("use-telemetry", false, "use-telemetry flag") | ||
return cmd | ||
} | ||
|
||
func mockCommandIComplete() *cobra.Command { | ||
cmd := &cobra.Command{} | ||
cmd.Flags().Bool("ci", false, "ci flag") | ||
return cmd | ||
} | ||
|
||
func TestRunK3dShouldReturnErrorIfSomeFlagIsNotPresent(t *testing.T) { | ||
cmd := mockCommandIComplete() | ||
args := []string{"create"} | ||
err := runK3d(cmd, args) | ||
|
||
errorExpected := "flag accessed but not defined: cluster-name" | ||
if errorExpected != err.Error() { | ||
t.Errorf("runK3d(%q) returned an error: %v", args, err) | ||
} | ||
} |