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

Commit bae77f0

Browse files
author
Russtopia
authored
Merge pull request #74 from cdr/4411-coder-cli-named-devurls
Add custom prefix devurl
2 parents 13fb3ca + 1dc6c3b commit bae77f0

File tree

6 files changed

+275
-82
lines changed

6 files changed

+275
-82
lines changed

ci/integration/devurls_test.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package integration
2+
3+
import (
4+
"context"
5+
"testing"
6+
"time"
7+
8+
"cdr.dev/coder-cli/ci/tcli"
9+
"cdr.dev/slog/sloggers/slogtest/assert"
10+
)
11+
12+
func TestDevURLCLI(t *testing.T) {
13+
t.Parallel()
14+
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
15+
defer cancel()
16+
17+
c, err := tcli.NewContainerRunner(ctx, &tcli.ContainerConfig{
18+
Image: "codercom/enterprise-dev",
19+
Name: "coder-cli-devurl-tests",
20+
BindMounts: map[string]string{
21+
binpath: "/bin/coder",
22+
},
23+
})
24+
assert.Success(t, "new run container", err)
25+
defer c.Close()
26+
27+
c.Run(ctx, "which coder").Assert(t,
28+
tcli.Success(),
29+
tcli.StdoutMatches("/usr/sbin/coder"),
30+
tcli.StderrEmpty(),
31+
)
32+
33+
c.Run(ctx, "coder urls ls").Assert(t,
34+
tcli.Error(),
35+
)
36+
37+
// The following cannot be enabled nor verified until either the
38+
// integration testing dogfood target has environments created, or
39+
// we implement the 'env create' command for coder-cli to create our
40+
// own here.
41+
42+
// If we were to create an env ourselves ... we could test devurls something like
43+
44+
// // == Login
45+
// headlessLogin(ctx, t, c)
46+
47+
// // == urls ls should fail w/o supplying an envname
48+
// c.Run(ctx, "coder urls ls").Assert(t,
49+
// tcli.Error(),
50+
// )
51+
52+
// // == env creation should succeed
53+
// c.Run(ctx, "coder envs create env1 --from image1 --cores 1 --ram 2gb --disk 10gb --nogpu").Assert(t,
54+
// tcli.Success())
55+
56+
// // == urls ls should succeed for a newly-created environment
57+
// var durl entclient.DevURL
58+
// c.Run(ctx, `coder urls ls -o json`).Assert(t,
59+
// tcli.Success(),
60+
// jsonUnmarshals(&durl), // though if a new env, durl should be empty
61+
// )
62+
63+
// // == devurl creation w/default PRIVATE access
64+
// c.Run(ctx, `coder urls create env1 3000`).Assert(t,
65+
// tcli.Success())
66+
67+
// // == devurl create w/access == AUTHED
68+
// c.Run(ctx, `coder urls create env1 3001 --access=AUTHED`).Assert(t,
69+
// tcli.Success())
70+
71+
// // == devurl create with name
72+
// c.Run(ctx, `coder urls create env1 3002 --access=PUBLIC --name=foobar`).Assert(t,
73+
// tcli.Success())
74+
75+
// // == devurl ls should return well-formed entries incl. one with AUTHED access
76+
// c.Run(ctx, `coder urls ls env1 -o json | jq -c '.[] | select( .access == "AUTHED")'`).Assert(t,
77+
// tcli.Success(),
78+
// jsonUnmarshals(&durl))
79+
80+
// // == devurl ls should return well-formed entries incl. one with name 'foobar'
81+
// c.Run(ctx, `coder urls ls env1 -o json | jq -c '.[] | select( .name == "foobar")'`).Assert(t,
82+
// tcli.Success(),
83+
// jsonUnmarshals(&durl))
84+
85+
// // == devurl rm should function
86+
// c.Run(ctx, `coder urls rm env1 3002`).Assert(t,
87+
// tcli.Success())
88+
89+
// // == removed devurl should no longer be there
90+
// c.Run(ctx, `coder urls ls env1 -o json | jq -c '.[] | select( .name == "foobar")'`).Assert(t,
91+
// tcli.Error(),
92+
// jsonUnmarshals(&durl))
93+
94+
}

0 commit comments

Comments
 (0)