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

Commit1261969

Browse files
committed
Add ci readme
1 parent8212be0 commit1261969

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

‎ci/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ci
2+
3+
##integration tests
4+
5+
###`tcli`
6+
7+
Package`tcli` provides a framework for writing end-to-end CLI tests.
8+
Each test group can have its own container for executing commands in a consistent
9+
and isolated filesystem.
10+
11+
###prerequisites
12+
13+
Assign the following environment variables to run the integration tests
14+
against an existing Enterprise deployment instance.
15+
16+
```bash
17+
export CODER_URL=...
18+
export CODER_EMAIL=...
19+
export CODER_PASSWORD=...
20+
```
21+
22+
Then, simply run the test command from the project root
23+
24+
```sh
25+
gotest -v ./ci/integration
26+
```

‎ci/integration/integration_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ package integration
22

33
import (
44
"context"
5-
"encoding/json"
65
"math/rand"
76
"testing"
87
"time"
98

109
"cdr.dev/coder-cli/ci/tcli"
11-
"cdr.dev/slog"
1210
"cdr.dev/slog/sloggers/slogtest/assert"
1311
)
1412

@@ -76,14 +74,6 @@ func TestCoderCLI(t *testing.T) {
7674
)
7775
}
7876

79-
funcstdoutUnmarshalsJSON(targetinterface{}) tcli.Assertion {
80-
returnfunc(t*testing.T,r*tcli.CommandResult) {
81-
slog.Helper()
82-
err:=json.Unmarshal(r.Stdout,target)
83-
assert.Success(t,"json unmarshals",err)
84-
}
85-
}
86-
8777
varseededRand=rand.New(rand.NewSource(time.Now().UnixNano()))
8878

8979
funcrandString(lengthint)string {

‎ci/integration/users_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestUsers(t *testing.T) {
3636
varuser entclient.User
3737
c.Run(ctx,`coder users ls --output json | jq -c '.[] | select( .username == "charlie")'`).Assert(t,
3838
tcli.Success(),
39-
stdoutUnmarshalsJSON(&user),
39+
tcli.StdoutJSONUnmarshal(&user),
4040
)
4141
assert.Equal(t,"user email is as expected","charlie@coder.com",user.Email)
4242
assert.Equal(t,"username is as expected","Charlie",user.Name)

‎ci/tcli/tcli.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tcli
33
import (
44
"bytes"
55
"context"
6+
"encoding/json"
67
"fmt"
78
"io"
89
"os/exec"
@@ -329,3 +330,21 @@ func DurationGreaterThan(dur time.Duration) Assertion {
329330
}
330331
}
331332
}
333+
334+
// StdoutJSONUnmarshal attempts to unmarshal stdout into the given target
335+
funcStdoutJSONUnmarshal(targetinterface{})Assertion {
336+
returnfunc(t*testing.T,r*CommandResult) {
337+
slog.Helper()
338+
err:=json.Unmarshal(r.Stdout,target)
339+
assert.Success(t,"stdout json unmarshals",err)
340+
}
341+
}
342+
343+
// StderrJSONUnmarshal attempts to unmarshal stderr into the given target
344+
funcStderrJSONUnmarshal(targetinterface{})Assertion {
345+
returnfunc(t*testing.T,r*CommandResult) {
346+
slog.Helper()
347+
err:=json.Unmarshal(r.Stdout,target)
348+
assert.Success(t,"stderr json unmarshals",err)
349+
}
350+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp