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

Commit 8c20ab2

Browse files
committed
fixup! chore: add authentication init to unit tests
1 parent c43788c commit 8c20ab2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/cmd/cli_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,41 +64,48 @@ type result struct {
6464
}
6565

6666
func (r result) success(t *testing.T) {
67+
t.Helper()
6768
assert.Success(t, "execute command", r.exitErr)
6869
}
6970

7071
//nolint
7172
func (r result) stdoutContains(t *testing.T, substring string) {
73+
t.Helper()
7274
if !strings.Contains(r.outBuffer.String(), substring) {
7375
slogtest.Fatal(t, "stdout contains substring", slog.F("substring", substring), slog.F("stdout", r.outBuffer.String()))
7476
}
7577
}
7678

7779
//nolint
7880
func (r result) stdoutUnmarshals(t *testing.T, target interface{}) {
81+
t.Helper()
7982
err := json.Unmarshal(r.outBuffer.Bytes(), target)
8083
assert.Success(t, "unmarshal json", err)
8184
}
8285

8386
//nolint
8487
func (r result) stdoutEmpty(t *testing.T) {
88+
t.Helper()
8589
assert.Equal(t, "stdout empty", "", r.outBuffer.String())
8690
}
8791

8892
//nolint
8993
func (r result) stderrEmpty(t *testing.T) {
94+
t.Helper()
9095
assert.Equal(t, "stderr empty", "", r.errBuffer.String())
9196
}
9297

9398
//nolint
9499
func (r result) stderrContains(t *testing.T, substring string) {
100+
t.Helper()
95101
if !strings.Contains(r.errBuffer.String(), substring) {
96102
slogtest.Fatal(t, "stderr contains substring", slog.F("substring", substring), slog.F("stderr", r.errBuffer.String()))
97103
}
98104
}
99105

100106
//nolint
101107
func (r result) clogError(t *testing.T) clog.CLIError {
108+
t.Helper()
102109
var cliErr clog.CLIError
103110
if !xerrors.As(r.exitErr, &cliErr) {
104111
slogtest.Fatal(t, "expected clog error, none found", slog.Error(r.exitErr), slog.F("type", fmt.Sprintf("%T", r.exitErr)))
@@ -122,8 +129,8 @@ func execute(t *testing.T, in io.Reader, args ...string) result {
122129
err := cmd.Execute()
123130

124131
slogtest.Debug(t, "execute command",
125-
slog.F("outBuffer", outStream.String()),
126-
slog.F("errBuffer", errStream.String()),
132+
slog.F("out_buffer", outStream.String()),
133+
slog.F("err_buffer", errStream.String()),
127134
slog.F("args", args),
128135
slog.F("execute_error", err),
129136
)

0 commit comments

Comments
 (0)