Skip to content

Commit

Permalink
check if ns/project present
Browse files Browse the repository at this point in the history
Signed-off-by: anandrkskd <[email protected]>
  • Loading branch information
anandrkskd committed Sep 14, 2022
1 parent 77750ec commit 46b4161
Show file tree
Hide file tree
Showing 4 changed files with 17 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
ListNamespaceProject(name string)

GetActiveNamespace() string
GetEnvsDevFileDeployment(componentName, appName, projectName string) map[string]string
Expand Down
6 changes: 6 additions & 0 deletions tests/helper/helper_kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ func (kubectl KubectlRunner) HasNamespaceProject(name string) bool {
return strings.Contains(out, name)
}

func (kubectl KubectlRunner) ListNamespaceProject(name string) {
Eventually(func() string {
return Cmd(kubectl.path, "get", "ns").ShouldRun().Out()
}, 30, 5).Should(ContainSubstring(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) ListNamespaceProject(name string) {
Eventually(func() string {
return Cmd(oc.path, "get", "project").ShouldRun().Out()
}, 30, 5).Should(ContainSubstring(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.ListNamespaceProject(nsWithNoService)
commonVar.CliRunner.ListNamespaceProject(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.ListNamespaceProject(nsWithNoService)
commonVar.CliRunner.ListNamespaceProject(otherNS)

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

0 comments on commit 46b4161

Please sign in to comment.