From 91b2808f6a50b216afc2b58d8226d089f318adb7 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Wed, 8 Mar 2023 10:07:23 +0100 Subject: [PATCH] Fix potential issue with 'odo describe component' integration tests when Podman is installed When running locally with Podman installed, the error message no longer contains the reference to the namespace. --- .../cmd_describe_component_test.go | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/tests/integration/cmd_describe_component_test.go b/tests/integration/cmd_describe_component_test.go index 19abb4ff6bc..2febcb2238d 100644 --- a/tests/integration/cmd_describe_component_test.go +++ b/tests/integration/cmd_describe_component_test.go @@ -67,19 +67,36 @@ var _ = Describe("odo describe component command tests", func() { }) } - It("should fail, with cluster", func() { + It("should fail, with default cluster mode", func() { By("running odo describe component -o json with an unknown name", func() { res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "-o", "json").ShouldFail() stdout, stderr := res.Out(), res.Err() Expect(helper.IsJSON(stderr)).To(BeTrue()) Expect(stdout).To(BeEmpty()) - helper.JsonPathContentContain(stderr, "message", "no component found with name \"unknown-name\" in the namespace \""+commonVar.Project+"\"") + helper.JsonPathContentContain(stderr, "message", "no component found with name \"unknown-name\"") }) By("running odo describe component with an unknown name", func() { res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name").ShouldFail() stdout, stderr := res.Out(), res.Err() Expect(stdout).To(BeEmpty()) + Expect(stderr).To(ContainSubstring("no component found with name \"unknown-name\"")) + }) + }) + + It("should fail, with cluster", func() { + By("running odo describe component -o json with an unknown name", func() { + res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "cluster", "-o", "json").ShouldFail() + stdout, stderr := res.Out(), res.Err() + Expect(helper.IsJSON(stderr)).To(BeTrue()) + Expect(stdout).To(BeEmpty()) + helper.JsonPathContentContain(stderr, "message", "no component found with name \"unknown-name\" in the namespace \""+commonVar.Project+"\"") + }) + + By("running odo describe component with an unknown name", func() { + res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "cluster").ShouldFail() + stdout, stderr := res.Out(), res.Err() + Expect(stdout).To(BeEmpty()) Expect(stderr).To(ContainSubstring("no component found with name \"unknown-name\" in the namespace \"" + commonVar.Project + "\"")) }) }) @@ -197,7 +214,7 @@ var _ = Describe("odo describe component command tests", func() { }) } - It("should not describe the component from another directory", func() { + It("should not describe the component from another directory, with default cluster mode", func() { By("running with json output", func() { err := os.Chdir("/") Expect(err).NotTo(HaveOccurred()) @@ -205,7 +222,7 @@ var _ = Describe("odo describe component command tests", func() { stdout, stderr := res.Out(), res.Err() Expect(helper.IsJSON(stderr)).To(BeTrue()) Expect(stdout).To(BeEmpty()) - helper.JsonPathContentContain(stderr, "message", "no component found with name \""+cmpName+"\" in the namespace \""+commonVar.Project+"\"") + helper.JsonPathContentContain(stderr, "message", "no component found with name \""+cmpName+"\"") }) By("running with default output", func() { @@ -214,7 +231,28 @@ var _ = Describe("odo describe component command tests", func() { res := helper.Cmd("odo", "describe", "component", "--name", cmpName).ShouldFail() stdout, stderr := res.Out(), res.Err() Expect(stdout).To(BeEmpty()) - Expect(stderr).To(ContainSubstring("no component found with name \"" + cmpName + "\" in the namespace \"" + commonVar.Project + "\"")) + Expect(stderr).To(ContainSubstring("no component found with name %q", cmpName)) + }) + }) + + It("should not describe the component from another directory, with cluster", func() { + By("running with json output", func() { + err := os.Chdir("/") + Expect(err).NotTo(HaveOccurred()) + res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "-o", "json", "--platform", "cluster").ShouldFail() + stdout, stderr := res.Out(), res.Err() + Expect(helper.IsJSON(stderr)).To(BeTrue()) + Expect(stdout).To(BeEmpty()) + helper.JsonPathContentContain(stderr, "message", "no component found with name \""+cmpName+"\" in the namespace \""+commonVar.Project+"\"") + }) + + By("running with default output", func() { + err := os.Chdir("/") + Expect(err).NotTo(HaveOccurred()) + res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "--platform", "cluster").ShouldFail() + stdout, stderr := res.Out(), res.Err() + Expect(stdout).To(BeEmpty()) + Expect(stderr).To(ContainSubstring("no component found with name %q in the namespace %q", cmpName, commonVar.Project)) }) })