This repository was archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Merged
Migrate to cobra #86
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b957f37
Mirgation to urfave/cli
cmoog 9b1173e
Add table output to envs ls
cmoog ba92295
Improve url command
cmoog 3b70c19
Cleanup tests
cmoog 5f7d205
Fix all erorr handling to use errors
cmoog d664df2
Remove "failed to" from errs
cmoog 8212be0
Migrate to urfave/cli/v2
cmoog 1261969
Add ci readme
cmoog 74a130a
Migrate to cobra
cmoog be6bc28
Add completions for env names to be enabled later
cmoog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,26 @@ | ||
# ci | ||
|
||
## integration tests | ||
|
||
### `tcli` | ||
|
||
Package `tcli` provides a framework for writing end-to-end CLI tests. | ||
cmoog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Each test group can have its own container for executing commands in a consistent | ||
and isolated filesystem. | ||
|
||
### prerequisites | ||
|
||
Assign the following environment variables to run the integration tests | ||
against an existing Enterprise deployment instance. | ||
|
||
```bash | ||
export CODER_URL=... | ||
cmoog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export CODER_EMAIL=... | ||
export CODER_PASSWORD=... | ||
``` | ||
|
||
Then, simply run the test command from the project root | ||
|
||
```sh | ||
go test -v ./ci/integration | ||
``` |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,56 @@ | ||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"cdr.dev/coder-cli/ci/tcli" | ||
"cdr.dev/coder-cli/internal/entclient" | ||
"cdr.dev/slog/sloggers/slogtest/assert" | ||
) | ||
|
||
func TestUsers(t *testing.T) { | ||
t.Parallel() | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5) | ||
defer cancel() | ||
|
||
c, err := tcli.NewContainerRunner(ctx, &tcli.ContainerConfig{ | ||
Image: "codercom/enterprise-dev", | ||
Name: "users-cli-tests", | ||
BindMounts: map[string]string{ | ||
binpath: "/bin/coder", | ||
cmoog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}) | ||
assert.Success(t, "new run container", err) | ||
defer c.Close() | ||
|
||
c.Run(ctx, "which coder").Assert(t, | ||
tcli.Success(), | ||
tcli.StdoutMatches("/usr/sbin/coder"), | ||
tcli.StderrEmpty(), | ||
) | ||
|
||
headlessLogin(ctx, t, c) | ||
|
||
var user entclient.User | ||
c.Run(ctx, `coder users ls --output json | jq -c '.[] | select( .username == "charlie")'`).Assert(t, | ||
tcli.Success(), | ||
tcli.StdoutJSONUnmarshal(&user), | ||
) | ||
assert.Equal(t, "user email is as expected", "charlie@coder.com", user.Email) | ||
assert.Equal(t, "username is as expected", "Charlie", user.Name) | ||
|
||
c.Run(ctx, "coder users ls --output human | grep charlie").Assert(t, | ||
tcli.Success(), | ||
tcli.StdoutMatches("charlie"), | ||
) | ||
|
||
c.Run(ctx, "coder logout").Assert(t, | ||
tcli.Success(), | ||
) | ||
|
||
c.Run(ctx, "coder users ls").Assert(t, | ||
tcli.Error(), | ||
) | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to link to this from the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most readers of the
README
will be customers, not developers. Doesn't really make sense to bring attention to it in my view.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have to bring attention to it. Just put a link at the bottom. Customers/potential customers who care to look closely will be happy we document and care about these things.