diff --git a/tests/integration/interactive_init_test.go b/tests/integration/interactive_init_test.go index d71f4be31fd..916ae23b641 100644 --- a/tests/integration/interactive_init_test.go +++ b/tests/integration/interactive_init_test.go @@ -92,66 +92,107 @@ var _ = Describe("odo init interactive command tests", func() { hasMultipleVersions = true } }) - It("should allow for personalizing configurations", func() { - command := []string{"odo", "init"} - output, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { + Context("personalizing configuration", func() { + It("should allow to add and delete an env var", func() { + command := []string{"odo", "init"} + output, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { - helper.ExpectString(ctx, "Select language") - helper.SendLine(ctx, "Javascript") + helper.ExpectString(ctx, "Select language") + helper.SendLine(ctx, "Javascript") + + helper.ExpectString(ctx, "Select project type") + helper.SendLine(ctx, "") + + if hasMultipleVersions { + helper.ExpectString(ctx, "Select version") + helper.SendLine(ctx, "") + } + + helper.ExpectString(ctx, "Select container for which you want to change configuration?") + helper.ExpectString(ctx, "runtime") + helper.SendLine(ctx, "runtime") - helper.ExpectString(ctx, "Select project type") - helper.SendLine(ctx, "") + helper.ExpectString(ctx, "What configuration do you want change") + helper.SendLine(ctx, "Add new environment variable") + helper.ExpectString(ctx, "Enter new environment variable name:") + helper.SendLine(ctx, "DEBUG_PROJECT_PORT") + helper.ExpectString(ctx, "Enter value for \"DEBUG_PROJECT_PORT\" environment variable:") + helper.SendLine(ctx, "5858") - if hasMultipleVersions { - helper.ExpectString(ctx, "Select version") + helper.ExpectString(ctx, "What configuration do you want change") + helper.SendLine(ctx, "Delete environment variable \"DEBUG_PORT\"") + + helper.ExpectString(ctx, "What configuration do you want change") + // Default option is NOTHING - configuration is correct helper.SendLine(ctx, "") - } - helper.ExpectString(ctx, "Select container for which you want to change configuration?") - helper.ExpectString(ctx, "runtime") - helper.SendLine(ctx, "runtime") + helper.ExpectString(ctx, "Select container for which you want to change configuration?") + helper.SendLine(ctx, "") - helper.ExpectString(ctx, "What configuration do you want change") - helper.SendLine(ctx, "Add new port") - helper.ExpectString(ctx, "Enter port number:") - helper.SendLine(ctx, "5000") + helper.ExpectString(ctx, "Which starter project do you want to use") + helper.SendLine(ctx, "nodejs-starter") - helper.ExpectString(ctx, "What configuration do you want change") - helper.SendLine(ctx, "Add new environment variable") - helper.ExpectString(ctx, "Enter new environment variable name:") - helper.SendLine(ctx, "DEBUG_PROJECT_PORT") - helper.ExpectString(ctx, "Enter value for \"DEBUG_PROJECT_PORT\" environment variable:") - helper.SendLine(ctx, "5858") + helper.ExpectString(ctx, "Enter component name:") + helper.SendLine(ctx, "my-nodejs-app") - helper.ExpectString(ctx, "What configuration do you want change") - helper.SendLine(ctx, "Delete port \"3000\"") + helper.ExpectString(ctx, "Your new component 'my-nodejs-app' is ready in the current directory.") - helper.ExpectString(ctx, "What configuration do you want change") - helper.SendLine(ctx, "Delete environment variable \"DEBUG_PORT\"") + }) + Expect(err).To(BeNil()) + Expect(output).To(ContainSubstring("Your new component 'my-nodejs-app' is ready in the current directory.")) + Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml")) + helper.FileShouldContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "DEBUG_PROJECT_PORT") + helper.FileShouldNotContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "DEBUG_PORT") + }) + It("should allow to add and delete a port ", func() { + command := []string{"odo", "init"} + output, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { - helper.ExpectString(ctx, "What configuration do you want change") - // Default option is NOTHING - configuration is correct - helper.SendLine(ctx, "") + helper.ExpectString(ctx, "Select language") + helper.SendLine(ctx, "Javascript") - helper.ExpectString(ctx, "Select container for which you want to change configuration?") - helper.SendLine(ctx, "") + helper.ExpectString(ctx, "Select project type") + helper.SendLine(ctx, "") + + if hasMultipleVersions { + helper.ExpectString(ctx, "Select version") + helper.SendLine(ctx, "") + } + + helper.ExpectString(ctx, "Select container for which you want to change configuration?") + helper.ExpectString(ctx, "runtime") + helper.SendLine(ctx, "runtime") + + helper.ExpectString(ctx, "What configuration do you want change") + helper.SendLine(ctx, "Add new port") + helper.ExpectString(ctx, "Enter port number:") + helper.SendLine(ctx, "5000") - helper.ExpectString(ctx, "Which starter project do you want to use") - helper.SendLine(ctx, "nodejs-starter") + helper.ExpectString(ctx, "What configuration do you want change") + helper.SendLine(ctx, "Delete port \"3000\"") - helper.ExpectString(ctx, "Enter component name:") - helper.SendLine(ctx, "my-nodejs-app") + helper.ExpectString(ctx, "What configuration do you want change") + // Default option is NOTHING - configuration is correct + helper.SendLine(ctx, "") - helper.ExpectString(ctx, "Your new component 'my-nodejs-app' is ready in the current directory.") + helper.ExpectString(ctx, "Select container for which you want to change configuration?") + helper.SendLine(ctx, "") + helper.ExpectString(ctx, "Which starter project do you want to use") + helper.SendLine(ctx, "nodejs-starter") + + helper.ExpectString(ctx, "Enter component name:") + helper.SendLine(ctx, "my-nodejs-app") + + helper.ExpectString(ctx, "Your new component 'my-nodejs-app' is ready in the current directory.") + + }) + Expect(err).To(BeNil()) + Expect(output).To(ContainSubstring("Your new component 'my-nodejs-app' is ready in the current directory.")) + Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml")) + helper.FileShouldContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "5000") + helper.FileShouldNotContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "3000") }) - Expect(err).To(BeNil()) - Expect(output).To(ContainSubstring("Your new component 'my-nodejs-app' is ready in the current directory.")) - Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml")) - helper.FileShouldContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "5000") - helper.FileShouldNotContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "3000") - helper.FileShouldContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "DEBUG_PROJECT_PORT") - helper.FileShouldNotContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "DEBUG_PORT") }) })