From ff873d272817689bee017f009542c2b2bc0882b8 Mon Sep 17 00:00:00 2001 From: aallbright Date: Tue, 18 Feb 2020 07:10:27 -0500 Subject: [PATCH] Add tests around nonexistent profiles --- test/integration/functional_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index bb4efa3701..3aa4f95cdb 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -494,7 +494,25 @@ func validateLogsCmd(ctx context.Context, t *testing.T, profile string) { // validateProfileCmd asserts "profile" command functionality func validateProfileCmd(ctx context.Context, t *testing.T, profile string) { - rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", "list")) + // Profile command should not create a nonexistent profile + nonexistentProfile := "lis" + rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", nonexistentProfile)) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } + for _, word := range []string{fmt.Sprintf("Created a new profile : %s", nonexistentProfile), fmt.Sprintf("minikube profile was successfully set to %s", nonexistentProfile)} { + if strings.Contains(rr.Stdout.String(), word) { + t.Errorf("minikube profile should not create a nonexistent profile") + } + } + for _, word := range []string{fmt.Sprintf("profile \"%s\" not found", nonexistentProfile), fmt.Sprintf("if you want to create a profile you can by this command: minikube start -p %s", nonexistentProfile)} { + if !strings.Contains(rr.Stderr.String(), word) { + t.Errorf("minikube profile should provide guidance on how to create a nonexistent profile") + } + } + + // List profiles + rr, err = Run(t, exec.CommandContext(ctx, Target(), "profile", "list")) if err != nil { t.Errorf("%s failed: %v", rr.Args, err) }