-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test!: create ws e2e tests with subcommand updates (#166)
- Loading branch information
Showing
9 changed files
with
181 additions
and
54 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
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
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
6 changes: 3 additions & 3 deletions
6
docs/cli/flow_workspace_new.md → docs/cli/flow_workspace_create.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## flow workspace set | ||
|
||
Change the current workspace. | ||
|
||
``` | ||
flow workspace set NAME [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-f, --fixed Set the workspace mode to fixed | ||
-h, --help help for set | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-x, --non-interactive Disable displaying flow output via terminal UI rendering. This is only needed if the interactive output is enabled by default in flow's configuration. | ||
--sync Sync flow cache and workspaces | ||
--verbosity int Log verbosity level (-1 to 1) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [flow workspace](flow_workspace.md) - Manage flow workspaces. | ||
|
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
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,98 @@ | ||
package tests_test | ||
|
||
import ( | ||
stdCtx "context" | ||
"fmt" | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/jahvon/flow/internal/context" | ||
"github.com/jahvon/flow/tests/utils" | ||
) | ||
|
||
var _ = Describe("workspace e2e", Ordered, func() { | ||
var ( | ||
ctx *context.Context | ||
run *utils.CommandRunner | ||
|
||
wsName, wsPath, origWsName string | ||
) | ||
|
||
BeforeAll(func() { | ||
ctx = utils.NewContext(stdCtx.Background(), GinkgoT()) | ||
run = utils.NewE2ECommandRunner() | ||
tmp, err := os.MkdirTemp("", "flow-test-*") | ||
Expect(err).NotTo(HaveOccurred()) | ||
origWsName = ctx.Config.CurrentWorkspace | ||
wsName = "test-workspace" | ||
wsPath = tmp | ||
}) | ||
|
||
BeforeEach(func() { | ||
utils.ResetTestContext(ctx, GinkgoT()) | ||
}) | ||
|
||
AfterEach(func() { | ||
ctx.Finalize() | ||
}) | ||
|
||
AfterAll(func() { | ||
Expect(os.RemoveAll(wsPath)).To(Succeed()) | ||
}) | ||
|
||
When("creating a new workspace (flow workspace create)", func() { | ||
It("creates successfully", func() { | ||
stdOut := ctx.StdOut() | ||
Expect(run.Run(ctx, "workspace", "create", wsName, wsPath)).To(Succeed()) | ||
out, err := readFileContent(stdOut) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(out).To(ContainSubstring(fmt.Sprintf("Workspace '%s' created", wsName))) | ||
}) | ||
}) | ||
|
||
When("setting a workspace (flow workspace set)", func() { | ||
It("sets successfully", func() { | ||
Expect(run.Run(ctx, "workspace", "set", wsName)).To(Succeed()) | ||
out, err := readFileContent(ctx.StdOut()) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(out).To(ContainSubstring(fmt.Sprintf("Workspace set to %s", wsName))) | ||
}) | ||
}) | ||
|
||
When("getting a workspace (flow workspace view)", func() { | ||
It("should returns the workspace", func() { | ||
stdOut := ctx.StdOut() | ||
Expect(run.Run(ctx, "workspace", "view", wsName)).To(Succeed()) | ||
out, err := readFileContent(stdOut) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(out).To(ContainSubstring(wsName)) | ||
}) | ||
}) | ||
|
||
When("listing workspaces (flow workspace list)", func() { | ||
It("should return the list of workspaces", func() { | ||
stdOut := ctx.StdOut() | ||
Expect(run.Run(ctx, "workspace", "list")).To(Succeed()) | ||
out, err := readFileContent(stdOut) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(out).To(ContainSubstring(wsName)) | ||
}) | ||
}) | ||
|
||
When("deleting a workspace (flow workspace delete)", func() { | ||
It("should remove the workspace from the user config", func() { | ||
reader, writer, err := os.Pipe() | ||
Expect(err).NotTo(HaveOccurred()) | ||
_, err = writer.Write([]byte("yes\n")) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
ctx.SetIO(reader, ctx.StdOut()) | ||
Expect(run.Run(ctx, "workspace", "delete", origWsName)).To(Succeed()) | ||
out, err := readFileContent(ctx.StdOut()) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(out).To(ContainSubstring(fmt.Sprintf("Workspace '%s' deleted", origWsName))) | ||
}) | ||
}) | ||
}) |