Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitcc55a4a

Browse files
author
Russtopia
committed
Add future support for integration devurl tests
1 parentc71c3c9 commitcc55a4a

File tree

3 files changed

+105
-6
lines changed

3 files changed

+105
-6
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+
funcTestDevURLCLI(t*testing.T) {
13+
t.Parallel()
14+
ctx,cancel:=context.WithTimeout(context.Background(),time.Minute*5)
15+
defercancel()
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+
deferc.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 del should function
86+
// c.Run(ctx, `coder urls del 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+
}

‎cmd/coder/urls.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type DevURL struct {
4444
URLstring`json:"url"`
4545
Portint`json:"port"`
4646
Accessstring`json:"access"`
47+
Namestring`json:"name"`
4748
}
4849

4950
varurlAccessLevel=map[string]string{

‎internal/entclient/devurl.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import (
55
"net/http"
66
)
77

8+
// DevURL is the parsed json response record for a devURL from cemanager
9+
typeDevURLstruct {
10+
IDstring`json:"id"`
11+
URLstring`json:"url"`
12+
Portint`json:"port"`
13+
Accessstring`json:"access"`
14+
Namestring`json:"name"`
15+
}
16+
817
typedelDevURLRequeststruct {
918
EnvIDstring`json:"environment_id"`
1019
DevURLIDstring`json:"url_id"`
@@ -61,12 +70,7 @@ func (c Client) InsertDevURL(envID string, port int, name, access string) error
6170
returnnil
6271
}
6372

64-
typeupdateDevURLRequeststruct {
65-
EnvIDstring`json:"environment_id"`
66-
Portint`json:"port"`
67-
Accessstring`json:"access"`
68-
Namestring`json:"name"`
69-
}
73+
typeupdateDevURLRequestcreateDevURLRequest
7074

7175
// UpdateDevURL updates an existing devurl for the authenticated user
7276
func (cClient)UpdateDevURL(envID,urlIDstring,portint,name,accessstring)error {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp