Skip to content

Commit

Permalink
Separate the tests
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi Vala <[email protected]>
  • Loading branch information
valaparthvi committed Jun 22, 2023
1 parent d4af242 commit 207d24f
Showing 1 changed file with 85 additions and 44 deletions.
129 changes: 85 additions & 44 deletions tests/integration/interactive_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
})

Expand Down

0 comments on commit 207d24f

Please sign in to comment.