- Notifications
You must be signed in to change notification settings - Fork18
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
b957f37
9b1173e
ba92295
3b70c19
5f7d205
d664df2
8212be0
1261969
74a130a
be6bc28
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ci | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others.Learn more. Most readers of the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
## integration tests | ||
### `tcli` | ||
Package `tcli` provides a framework for writing end-to-end CLI tests. | ||
cmoog marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
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 resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
export CODER_EMAIL=... | ||
export CODER_PASSWORD=... | ||
``` | ||
Then, simply run the test command from the project root | ||
```sh | ||
go test -v ./ci/integration | ||
``` |
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 resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
}, | ||
}) | ||
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(), | ||
) | ||
} |
Uh oh!
There was an error while loading.Please reload this page.