-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doc automation:Command reference: odo delete,list and set namespace (#…
…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
Showing
12 changed files
with
248 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
docs/website/docs/command-reference/docs-mdx/delete-namespace/delete_namespace.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"? | ||
``` |
4 changes: 4 additions & 0 deletions
4
docs/website/docs/command-reference/docs-mdx/delete-namespace/delete_project.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"? | ||
``` |
12 changes: 12 additions & 0 deletions
12
docs/website/docs/command-reference/docs-mdx/list-namespace/list_namespace.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
12 changes: 12 additions & 0 deletions
12
docs/website/docs/command-reference/docs-mdx/list-namespace/list_project.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
4 changes: 4 additions & 0 deletions
4
docs/website/docs/command-reference/docs-mdx/set-namespace/set_namespace.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
``` |
4 changes: 4 additions & 0 deletions
4
docs/website/docs/command-reference/docs-mdx/set-namespace/set_project.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
tests/documentation/command-reference/doc_command_reference_deletenamespace_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
|
||
}) | ||
}) |
63 changes: 63 additions & 0 deletions
63
tests/documentation/command-reference/doc_command_reference_listnamespace_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
|
||
}) |
52 changes: 52 additions & 0 deletions
52
tests/documentation/command-reference/doc_command_reference_setnamespace_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
|
||
}) |