Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit d244d35

Browse files
authored
Allow integration tests to pass on fresh deployments (#131)
1 parent bf9a6ae commit d244d35

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

ci/integration/ssh_test.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,29 @@ import (
55
"testing"
66

77
"cdr.dev/coder-cli/ci/tcli"
8+
"cdr.dev/coder-cli/coder-sdk"
89
)
910

1011
func TestSSH(t *testing.T) {
1112
t.Parallel()
1213
run(t, "ssh-coder-cli-tests", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) {
1314
headlessLogin(ctx, t, c)
14-
c.Run(ctx, "coder config-ssh").Assert(t,
15+
16+
// TODO remove this once we can create an environment if there aren't any
17+
var envs []coder.Environment
18+
c.Run(ctx, "coder envs ls --output json").Assert(t,
1519
tcli.Success(),
20+
tcli.StdoutJSONUnmarshal(&envs),
21+
)
22+
23+
assert := tcli.Success()
24+
25+
// if we don't have any environments, "coder config-ssh" will fail
26+
if len(envs) == 0 {
27+
assert = tcli.Error()
28+
}
29+
c.Run(ctx, "coder config-ssh").Assert(t,
30+
assert,
1631
)
1732
})
1833
}

ci/integration/users_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ func TestUsers(t *testing.T) {
2121
headlessLogin(ctx, t, c)
2222

2323
var user coder.User
24-
c.Run(ctx, `coder users ls --output json | jq -c '.[] | select( .username == "charlie")'`).Assert(t,
24+
c.Run(ctx, `coder users ls --output json | jq -c '.[] | select( .username == "admin")'`).Assert(t,
2525
tcli.Success(),
2626
tcli.StdoutJSONUnmarshal(&user),
2727
)
28-
assert.Equal(t, "user email is as expected", "charlie@coder.com", user.Email)
29-
assert.Equal(t, "username is as expected", "Charlie", user.Name)
28+
assert.Equal(t, "user email is as expected", "admin", user.Email)
29+
assert.Equal(t, "name is as expected", "admin", user.Name)
3030

31-
c.Run(ctx, "coder users ls --output human | grep charlie").Assert(t,
31+
c.Run(ctx, "coder users ls --output human | grep admin").Assert(t,
3232
tcli.Success(),
33-
tcli.StdoutMatches("charlie"),
33+
tcli.StdoutMatches("admin"),
3434
)
3535

3636
c.Run(ctx, "coder logout").Assert(t,

0 commit comments

Comments
 (0)