Skip to content

Commit

Permalink
Doc automation:Command reference: odo delete,list and set namespace (#…
Browse files Browse the repository at this point in the history
…6756)

* Adding files for odo delete,list and set namespace

Signed-off-by: Ritu Deshmukh <[email protected]>

* Changes to be added

Signed-off-by: Ritu Deshmukh <[email protected]>

* Modified changes

Signed-off-by: Ritu Deshmukh <[email protected]>

* Adding changes based on review

Signed-off-by: Ritu Deshmukh <[email protected]>

---------

Signed-off-by: Ritu Deshmukh <[email protected]>
  • Loading branch information
ritudes authored Apr 27, 2023
1 parent b57d3e2 commit 5913097
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 42 deletions.
16 changes: 6 additions & 10 deletions docs/website/docs/command-reference/delete-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ odo delete namespace <name> [--wait] [--force]
<details>
<summary>Example</summary>

```shell
$ odo delete namespace mynamespace
? Are you sure you want to delete namespace "mynamespace"? Yes
✓ Namespace "mynamespace" will be deleted asynchronously
```
import DeleteNamespace from './docs-mdx/delete-namespace/delete_namespace.mdx';

<DeleteNamespace />
</details>

Optionally, you can also use `project` as an alias to `namespace`.
Expand All @@ -28,11 +26,9 @@ odo delete project <name> [--wait] [--force]
<details>
<summary>Example</summary>

```shell
$ odo delete project myproject
? Are you sure you want to delete project "myproject"? Yes
✓ Project "myproject" will be deleted asynchronously
```
import DeleteProject from './docs-mdx/delete-namespace/delete_project.mdx';

<DeleteProject />
</details>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```console
$ odo delete
? Are you sure you want to delete namespace "odo-dev"?
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```console
$ odo delete
? Are you sure you want to delete project "odo-dev"?
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```console
$ odo list namespace
ACTIVE NAME
* default
kube-node-lease
kube-public
kube-system
mynamespace
myproject
olm
operators
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```console
$ odo list project
ACTIVE NAME
* default
kube-node-lease
kube-public
kube-system
mynamespace
myproject
olm
operators
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```console
$ odo set namespace odo-dev
✓ Current active namespace set to "odo-dev"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```console
$ odo set project odo-dev
✓ Current active project set to "odo-dev"
```
30 changes: 6 additions & 24 deletions docs/website/docs/command-reference/list-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,9 @@ odo list namespace
<details>
<summary>Example</summary>

```console
$ odo list namespace
ACTIVE NAME
* default
kube-node-lease
kube-public
kube-system
mynamespace
myproject
olm
operators
```
import ListNamespace from './docs-mdx/list-namespace/list_namespace.mdx';

<ListNamespace />
</details>


Expand All @@ -40,18 +31,9 @@ odo list project
<details>
<summary>Example</summary>

```console
$ odo list project
ACTIVE NAME
* default
kube-node-lease
kube-public
kube-system
mynamespace
myproject
olm
operators
```
import ListProject from './docs-mdx/list-namespace/list_project.mdx';

<ListProject />
</details>


Expand Down
14 changes: 6 additions & 8 deletions docs/website/docs/command-reference/set-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ odo set namespace <namespace>
<details>
<summary>Example</summary>

```console
$ odo set namespace mynamespace
✓ Current active namespace set to "mynamespace"
```
import SetNamespace from './docs-mdx/set-namespace/set_namespace.mdx';

<SetNamespace />
</details>

Optionally, you can also use `project` as an alias to `namespace`.
Expand All @@ -29,10 +28,9 @@ odo set project <project>
<details>
<summary>Example</summary>

```console
$ odo set project myproject
✓ Current active project set to "myproject"
```
import SetProject from './docs-mdx/set-namespace/set_project.mdx';

<SetProject />
</details>

:::tip
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package docautomation

import (
"fmt"
"path/filepath"

"github.com/google/go-cmp/cmp"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/redhat-developer/odo/tests/helper"
)

var _ = Describe("doc command reference odo delete namespace", func() {
var commonVar helper.CommonVar
var commonPath = filepath.Join("command-reference", "docs-mdx", "delete-namespace")
var outputStringFormat = "```console\n$ odo %s\n%s```\n"

BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
})

AfterEach(func() {
helper.CommonAfterEach(commonVar)
})

Context("To delete a namespace resource", func() {

BeforeEach(func() {
helper.Cmd("odo", "create", "namespace", "odo-dev").ShouldPass()

})

AfterEach(func() {
commonVar.CliRunner.DeleteNamespaceProject("odo-dev", true)
})

It("Deletes a namespace resource for a kubernetes cluster", func() {
args := []string{"odo", "delete", "namespace", "odo-dev"}
out, err := helper.RunInteractive(args, []string{"ODO_LOG_LEVEL=0"}, func(ctx helper.InteractiveContext) {
helper.ExpectString(ctx, "? Are you sure you want to delete namespace \"odo-dev\"?")
helper.SendLine(ctx, "Yes")

})
Expect(err).To(BeNil())
got := helper.StripAnsi(out)
got = helper.StripInteractiveQuestion(got)
got = fmt.Sprintf(outputStringFormat, args[1], helper.StripSpinner(got))
file := "delete_namespace.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
Expect(diff).To(BeEmpty(), file)
})

It("Deletes a project resource for a openshift cluster", func() {
args := []string{"odo", "delete", "project", "odo-dev"}
out, err := helper.RunInteractive(args, []string{"ODO_LOG_LEVEL=0"}, func(ctx helper.InteractiveContext) {
helper.ExpectString(ctx, "? Are you sure you want to delete project \"odo-dev\"?")
helper.SendLine(ctx, "Yes")

})
Expect(err).To(BeNil())
got := helper.StripAnsi(out)
got = helper.StripInteractiveQuestion(got)
got = fmt.Sprintf(outputStringFormat, args[1], helper.StripSpinner(got))
file := "delete_project.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
Expect(diff).To(BeEmpty(), file)
})

})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package docautomation

import (
"fmt"
"path/filepath"
"strings"

"github.com/google/go-cmp/cmp"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/redhat-developer/odo/tests/helper"
)

var _ = Describe("doc command reference odo list namespace", func() {
var commonVar helper.CommonVar
var commonPath = filepath.Join("command-reference", "docs-mdx", "list-namespace")
var outputStringFormat = "```console\n$ odo %s\n%s```\n"
var namespacelist = `
* default
kube-node-lease
kube-public
kube-system
mynamespace
myproject
olm
operators`

BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
})

AfterEach(func() {
helper.CommonAfterEach(commonVar)
})

Context("To list all available namespaces", func() {

It("Lists all namespace resources available in a kubernetes cluster", func() {
args := []string{"list", "namespace"}
out := helper.Cmd("odo", args...).ShouldPass().Out()
out = strings.SplitAfter(out, "NAME")[0] + namespacelist
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
file := "list_namespace.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
Expect(diff).To(BeEmpty(), file)
})

It("Lists all project resources available in a openshift cluster", func() {
args := []string{"list", "project"}
out := helper.Cmd("odo", args...).ShouldPass().Out()
out = strings.SplitAfter(out, "NAME")[0] + namespacelist
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
file := "list_project.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
Expect(diff).To(BeEmpty(), file)
})
})

})
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package docautomation

import (
"fmt"
"path/filepath"
"strings"

"github.com/google/go-cmp/cmp"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/redhat-developer/odo/tests/helper"
)

var _ = Describe("doc command reference odo set namespace", func() {
var commonVar helper.CommonVar
var commonPath = filepath.Join("command-reference", "docs-mdx", "set-namespace")
var outputStringFormat = "```console\n$ odo %s\n%s```\n"

BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
})

AfterEach(func() {
helper.CommonAfterEach(commonVar)
})

Context("To set an active namespace resource", func() {

It("Sets a namespace resource to be current active on a kubernetes cluster", func() {
args := []string{"set", "namespace", "odo-dev"}
out := helper.Cmd("odo", args...).ShouldPass().Out()
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
file := "set_namespace.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
Expect(diff).To(BeEmpty(), file)
})

It("Sets a project resource to be current active on a openshift cluster", func() {
args := []string{"set", "project", "odo-dev"}
out := helper.Cmd("odo", args...).ShouldPass().Out()
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
file := "set_project.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
Expect(diff).To(BeEmpty(), file)
})
})

})

0 comments on commit 5913097

Please sign in to comment.