Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc automation:Command reference: odo delete,list and set namespace #6756

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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").ShouldRun()
ritudes marked this conversation as resolved.
Show resolved Hide resolved

})

AfterEach(func() {
commonVar.CliRunner.DeleteNamespaceProject("odo-dev", false)
ritudes marked this conversation as resolved.
Show resolved Hide resolved
})

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)
})
})

})