Skip to content

Commit 805197b

Browse files
committed
Pass lint and test
1 parent 3e68480 commit 805197b

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

.golangci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
linter-settings:
2+
linters:
3+
disable:
4+
- errcheck

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SHELL = /bin/bash
2+
.ONESHELL:
3+
4+
.PHONY: lint
5+
lint:
6+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
7+
~/go/bin/golangci-lint run
8+
9+
.PHONY: test
10+
test:
11+
go test -timeout=3m -race .

cmd_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestCommand(t *testing.T) {
116116
),
117117
)
118118
if verbose {
119-
i.Stdout.Write([]byte("!!!"))
119+
_, _ = i.Stdout.Write([]byte("!!!"))
120120
}
121121
return nil
122122
},
@@ -129,7 +129,8 @@ func TestCommand(t *testing.T) {
129129
t.Parallel()
130130
i := cmd().Invoke("toupper", "hello")
131131
io := fakeIO(i)
132-
i.Run()
132+
err := i.Run()
133+
require.NoError(t, err)
133134
require.Equal(t, "HELLO", io.Stdout.String())
134135
})
135136

@@ -139,7 +140,9 @@ func TestCommand(t *testing.T) {
139140
"up", "hello",
140141
)
141142
io := fakeIO(i)
142-
i.Run()
143+
err := i.Run()
144+
require.NoError(t, err)
145+
143146
require.Equal(t, "HELLO", io.Stdout.String())
144147
})
145148

@@ -326,7 +329,7 @@ func TestCommand_DeepNest(t *testing.T) {
326329
{
327330
Use: "3",
328331
Handler: func(i *serpent.Invocation) error {
329-
i.Stdout.Write([]byte("3"))
332+
_, _ = i.Stdout.Write([]byte("3"))
330333
return nil
331334
},
332335
},
@@ -432,7 +435,7 @@ func TestCommand_RawArgs(t *testing.T) {
432435
if v := i.ParsedFlags().Lookup("password").Value.String(); v != "codershack" {
433436
return xerrors.Errorf("password %q is wrong!", v)
434437
}
435-
i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
438+
_, _ = i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
436439
return nil
437440
}),
438441
},
@@ -480,7 +483,7 @@ func TestCommand_RootRaw(t *testing.T) {
480483
cmd := &serpent.Cmd{
481484
RawArgs: true,
482485
Handler: func(i *serpent.Invocation) error {
483-
i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
486+
_, _ = i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
484487
return nil
485488
},
486489
}
@@ -497,7 +500,7 @@ func TestCommand_HyphenHyphen(t *testing.T) {
497500
t.Parallel()
498501
cmd := &serpent.Cmd{
499502
Handler: (func(i *serpent.Invocation) error {
500-
i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
503+
_, _ = i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
501504
return nil
502505
}),
503506
}
@@ -538,7 +541,7 @@ func TestCommand_Help(t *testing.T) {
538541
return &serpent.Cmd{
539542
Use: "root",
540543
HelpHandler: (func(i *serpent.Invocation) error {
541-
i.Stdout.Write([]byte("abdracadabra"))
544+
_, _ = i.Stdout.Write([]byte("abdracadabra"))
542545
return nil
543546
}),
544547
Handler: (func(i *serpent.Invocation) error {

0 commit comments

Comments
 (0)