From 3042f57eb0e3c7777d51b6db19988e43adccb9bf Mon Sep 17 00:00:00 2001 From: Jairo Fernandez Date: Sun, 22 Oct 2023 00:25:03 -0500 Subject: [PATCH] test: k3d just valid github user or github org with create command --- cmd/k3d/create_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/k3d/create_test.go b/cmd/k3d/create_test.go index c6276e26f..c1c7222cd 100644 --- a/cmd/k3d/create_test.go +++ b/cmd/k3d/create_test.go @@ -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) @@ -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) + } +}