Skip to content

Commit

Permalink
Merge dd1824b into dcbc60a
Browse files Browse the repository at this point in the history
  • Loading branch information
valaparthvi authored May 26, 2023
2 parents dcbc60a + dd1824b commit 3ce5100
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions tests/integration/cmd_describe_list_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
When(fmt.Sprintf("creating a component with a binding (service in namespace %q)", ns), func() {
cmpName := "my-nodejs-app"
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-service-binding-files.yaml")).ShouldPass()
if ns != "" {
helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"),
Expand Down Expand Up @@ -92,7 +93,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
{"list"},
} {
command := command
It(fmt.Sprintf("should list the binding without running odo dev (%v)", command), func() {
It(fmt.Sprintf("should list the binding without running odo dev (%s)", command), func() {
By("JSON output", func() {
res := helper.Cmd("odo", append(command, "-o", "json")...).ShouldPass()
stdout, stderr := res.Out(), res.Err()
Expand Down Expand Up @@ -157,7 +158,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
assertDescribeNamedJsonOutput func(stdout, stderr string, name string)
assertDescribeNamedHumanReadableOutput func(stdout, stderr string, name string)
assertListJsonOutput func(devfile bool, stdout, stderr string)
assertListHumanReadableOutput func(devfile bool, stdout, stderr string)
assertListHumanReadableOutput func(devfile bool, stdout, stderr string, command []string)
}{
{
title: "creating a component with a binding as files",
Expand Down Expand Up @@ -269,9 +270,14 @@ var _ = Describe("odo describe/list binding command tests", func() {

helper.JsonPathContentIs(stdout, "bindings.1.name", "my-nodejs-app-cluster-sample-ocp")
},
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string) {
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string, command []string) {
lines := strings.Split(stdout, "\n")
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
if len(command) == 1 {
Expect(lines[0]).To(ContainSubstring(fmt.Sprintf("Listing resources from the namespace %q", commonVar.Project)))
lines = lines[6:]
} else {
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
}
if devfile {
Expect(lines[3]).To(ContainSubstring("* "))
} else {
Expand Down Expand Up @@ -401,9 +407,14 @@ var _ = Describe("odo describe/list binding command tests", func() {
helper.JsonPathContentIs(stdout, "bindings.1.name", "my-nodejs-app-cluster-sample-ocp")

},
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string) {
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string, command []string) {
lines := strings.Split(stdout, "\n")
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
if len(command) == 1 {
Expect(lines[0]).To(ContainSubstring(fmt.Sprintf("Listing resources from the namespace %q", commonVar.Project)))
lines = lines[6:]
} else {
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
}
if devfile {
Expect(lines[3]).To(ContainSubstring("* "))
} else {
Expand Down Expand Up @@ -513,9 +524,14 @@ var _ = Describe("odo describe/list binding command tests", func() {

helper.JsonPathContentIs(stdout, "bindings.1.name", "my-nodejs-app-cluster-sample-ocp")
},
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string) {
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string, command []string) {
lines := strings.Split(stdout, "\n")
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
if len(command) == 1 {
Expect(lines[0]).To(ContainSubstring(fmt.Sprintf("Listing resources from the namespace %q", commonVar.Project)))
lines = lines[6:]
} else {
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
}
if devfile {
Expect(lines[3]).To(ContainSubstring("* "))
} else {
Expand Down Expand Up @@ -622,9 +638,14 @@ var _ = Describe("odo describe/list binding command tests", func() {

helper.JsonPathContentIs(stdout, "bindings.1.name", "my-nodejs-app-cluster-sample-ocp")
},
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string) {
assertListHumanReadableOutput: func(devfile bool, stdout, stderr string, command []string) {
lines := strings.Split(stdout, "\n")
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
if len(command) == 1 {
Expect(lines[0]).To(ContainSubstring(fmt.Sprintf("Listing resources from the namespace %q", commonVar.Project)))
lines = lines[6:]
} else {
Expect(lines[0]).To(ContainSubstring("Listing ServiceBindings"))
}
if devfile {
Expect(lines[3]).To(ContainSubstring("* "))
} else {
Expand All @@ -645,6 +666,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
When(fmt.Sprintf("%s (service in namespace %q)", ctx.title, ns), func() {
cmpName := "my-nodejs-app"
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", ctx.devfile).ShouldPass()
})

Expand Down Expand Up @@ -739,7 +761,8 @@ var _ = Describe("odo describe/list binding command tests", func() {
{"list"},
{"list", "binding"},
} {
It("should list the binding", func() {
command := command
It(fmt.Sprintf("should list the binding - command: %v", command), func() {
By("JSON output", func() {
res := helper.Cmd("odo", append(command, "-o", "json")...).ShouldPass()
stdout, stderr := res.Out(), res.Err()
Expand All @@ -751,7 +774,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
res := helper.Cmd("odo", command...).ShouldPass()
stdout, stderr := res.Out(), res.Err()
if ctx.assertListHumanReadableOutput != nil {
ctx.assertListHumanReadableOutput(true, stdout, stderr)
ctx.assertListHumanReadableOutput(true, stdout, stderr, command)
}
})

Expand All @@ -770,7 +793,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
res := helper.Cmd("odo", command...).ShouldPass()
stdout, stderr := res.Out(), res.Err()
if ctx.assertListHumanReadableOutput != nil {
ctx.assertListHumanReadableOutput(false, stdout, stderr)
ctx.assertListHumanReadableOutput(false, stdout, stderr, command)
}
})
})
Expand All @@ -784,7 +807,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
commonVar.CliRunner.SetProject(commonVar.Project)
})

It("should list the binding with --namespace flag", func() {
It(fmt.Sprintf("should list the binding with --namespace flag - command: %s", command), func() {
By("JSON output from another directory", func() {
err := os.Chdir("/")
Expect(err).ToNot(HaveOccurred())
Expand All @@ -800,7 +823,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
res := helper.Cmd("odo", append(command, "--namespace", commonVar.Project)...).ShouldPass()
stdout, stderr := res.Out(), res.Err()
if ctx.assertListHumanReadableOutput != nil {
ctx.assertListHumanReadableOutput(false, stdout, stderr)
ctx.assertListHumanReadableOutput(false, stdout, stderr, command)
}
})
})
Expand Down

0 comments on commit 3ce5100

Please sign in to comment.