Skip to content

Commit

Permalink
check if namespace is created instead of project
Browse files Browse the repository at this point in the history
Signed-off-by: anandrkskd <[email protected]>
  • Loading branch information
anandrkskd committed Sep 13, 2022
1 parent 77750ec commit f9fc5ab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/helper/helper_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type CliRunner interface {

// HasNamespaceProject returns whether the specified namespace or project exists in the cluster
HasNamespaceProject(name string) bool
HasNamespace(name string)

GetActiveNamespace() string
GetEnvsDevFileDeployment(componentName, appName, projectName string) map[string]string
Expand Down
5 changes: 5 additions & 0 deletions tests/helper/helper_kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ func (kubectl KubectlRunner) HasNamespaceProject(name string) bool {
ShouldRun().Out()
return strings.Contains(out, name)
}
func (kubectl KubectlRunner) HasNamespace(name string) {
Eventually(func() string {
return Cmd(kubectl.path, "get", "ns", name, "-o", "jsonpath={.metadata.name}").ShouldRun().Out()
}, 30*time.Second, 1*time.Second).Should(Equal(name))
}

func (kubectl KubectlRunner) GetActiveNamespace() string {
return Cmd(kubectl.path, "config", "view", "--minify", "-ojsonpath={..namespace}").ShouldPass().Out()
Expand Down
6 changes: 6 additions & 0 deletions tests/helper/helper_oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,12 @@ func (oc OcRunner) HasNamespaceProject(name string) bool {
return strings.Contains(out, name)
}

func (oc OcRunner) HasNamespace(name string) {
Eventually(func() string {
return Cmd(oc.path, "get", "ns", name, "-o", "jsonpath={.metadata.name}").ShouldRun().Out()
}, 30*time.Second, 1*time.Second).Should(Equal(name))
}

func (oc OcRunner) GetActiveNamespace() string {
return Cmd(oc.path, "config", "view", "--minify", "-ojsonpath={..namespace}").ShouldPass().Out()
}
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/interactive_add_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ var _ = Describe("odo add binding interactive command tests", func() {
helper.GetExamplePath("manifests", "bindablekind-instance.yaml"))
Expect(addBindableKindInOtherNs.ExitCode()).To(BeEquivalentTo(0))
nsWithNoService = commonVar.CliRunner.CreateAndSetRandNamespaceProject()
Expect(commonVar.CliRunner.HasNamespaceProject(nsWithNoService)).Should(Equal(true))
Expect(commonVar.CliRunner.HasNamespaceProject(otherNS)).Should(Equal(true))
commonVar.CliRunner.HasNamespace(nsWithNoService)
commonVar.CliRunner.HasNamespace(otherNS)

commonVar.CliRunner.SetProject(commonVar.Project)
})
Expand Down Expand Up @@ -558,8 +558,8 @@ var _ = Describe("odo add binding interactive command tests", func() {
helper.GetExamplePath("manifests", "bindablekind-instance.yaml"))
Expect(addBindableKindInOtherNs.ExitCode()).To(BeEquivalentTo(0))
nsWithNoService = commonVar.CliRunner.CreateAndSetRandNamespaceProject()
Expect(commonVar.CliRunner.HasNamespaceProject(nsWithNoService)).Should(Equal(true))
Expect(commonVar.CliRunner.HasNamespaceProject(otherNS)).Should(Equal(true))
commonVar.CliRunner.HasNamespace(nsWithNoService)
commonVar.CliRunner.HasNamespace(otherNS)

commonVar.CliRunner.SetProject(commonVar.Project)
})
Expand Down

0 comments on commit f9fc5ab

Please sign in to comment.