From 34e4b1bf68a39d26510a808fa0f0ccc1e7a95213 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Wed, 23 Sep 2020 13:21:31 -0500 Subject: [PATCH 1/2] Allow integration tests to pass on fresh deployments --- ci/integration/ssh_test.go | 17 ++++++++++++++++- ci/integration/users_test.go | 10 +++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ci/integration/ssh_test.go b/ci/integration/ssh_test.go index 273e3850..07dc1ba6 100644 --- a/ci/integration/ssh_test.go +++ b/ci/integration/ssh_test.go @@ -5,14 +5,29 @@ import ( "testing" "cdr.dev/coder-cli/ci/tcli" + "cdr.dev/coder-cli/coder-sdk" ) func TestSSH(t *testing.T) { t.Parallel() run(t, "ssh-coder-cli-tests", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) { headlessLogin(ctx, t, c) - c.Run(ctx, "coder config-ssh").Assert(t, + + // TODO remove this once we can create an environment if there aren't any + var envs []coder.Environment + c.Run(ctx, "coder envs ls --output json").Assert(t, tcli.Success(), + tcli.StdoutJSONUnmarshal(&envs), + ) + + assert := tcli.Success() + + // if we don't have any environments, "coder config-ssh" will fail + if len(envs) > 0 { + assert = tcli.Error() + } + c.Run(ctx, "coder config-ssh").Assert(t, + assert, ) }) } diff --git a/ci/integration/users_test.go b/ci/integration/users_test.go index 05d81c6a..2138aeed 100644 --- a/ci/integration/users_test.go +++ b/ci/integration/users_test.go @@ -21,16 +21,16 @@ func TestUsers(t *testing.T) { headlessLogin(ctx, t, c) var user coder.User - c.Run(ctx, `coder users ls --output json | jq -c '.[] | select( .username == "charlie")'`).Assert(t, + c.Run(ctx, `coder users ls --output json | jq -c '.[] | select( .username == "admin")'`).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) + assert.Equal(t, "user email is as expected", "admin", user.Email) + assert.Equal(t, "name is as expected", "admin", user.Name) - c.Run(ctx, "coder users ls --output human | grep charlie").Assert(t, + c.Run(ctx, "coder users ls --output human | grep admin").Assert(t, tcli.Success(), - tcli.StdoutMatches("charlie"), + tcli.StdoutMatches("admin"), ) c.Run(ctx, "coder logout").Assert(t, From 9ecc9385c9a0eb7cb5ec83889b1e9bd89343082f Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Wed, 23 Sep 2020 13:22:52 -0500 Subject: [PATCH 2/2] fixup! Allow integration tests to pass on fresh deployments --- ci/integration/ssh_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/integration/ssh_test.go b/ci/integration/ssh_test.go index 07dc1ba6..3882b719 100644 --- a/ci/integration/ssh_test.go +++ b/ci/integration/ssh_test.go @@ -23,7 +23,7 @@ func TestSSH(t *testing.T) { assert := tcli.Success() // if we don't have any environments, "coder config-ssh" will fail - if len(envs) > 0 { + if len(envs) == 0 { assert = tcli.Error() } c.Run(ctx, "coder config-ssh").Assert(t,