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

Commit e26341d

Browse files
committed
fixup! Add ci readme
1 parent bd3d352 commit e26341d

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

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-
func stdoutUnmarshalsJSON(target interface{}) tcli.Assertion {
80-
return func(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
var seededRand = rand.New(rand.NewSource(time.Now().UnixNano()))
8878

8979
func randString(length int) 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
var user 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+
func StdoutJSONUnmarshal(target interface{}) Assertion {
336+
return func(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+
func StderrJSONUnmarshal(target interface{}) Assertion {
345+
return func(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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy