Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
segevfiner committed Feb 1, 2022
1 parent 809037c commit 75f8b6c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions dockerexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ func TestMain(m *testing.M) {
}
defer pullOutput.Close()

jsonmessage.DisplayJSONMessagesStream(pullOutput, os.Stderr, 0, false, nil)
err = jsonmessage.DisplayJSONMessagesStream(pullOutput, os.Stderr, 0, false, nil)
if err != nil {
panic(err)
}
} else {
panic(err)
}
Expand Down Expand Up @@ -125,15 +128,15 @@ func TestExitStatus(t *testing.T) {
func TestExitCode(t *testing.T) {
// Test that exit code are returned correctly
cmd := dockerexec.Command(dockerClient, testImage, "sh", "-c", "exit 42")
cmd.Run()
_ = cmd.Run()
assert.Equal(t, int64(42), cmd.StatusCode)

cmd = dockerexec.Command(dockerClient, testImage, "sh", "-c", "exit 255")
cmd.Run()
_ = cmd.Run()
assert.Equal(t, int64(255), cmd.StatusCode)

cmd = dockerexec.Command(dockerClient, testImage, "cat")
cmd.Run()
_ = cmd.Run()
assert.Equal(t, int64(0), cmd.StatusCode)

// Test when command does not call Run().
Expand Down Expand Up @@ -185,17 +188,19 @@ func TestContext(t *testing.T) {
defer cancel()

cmd := dockerexec.CommandContext(ctx, dockerClient, testImage, "sleep", "120")
cmd.Start()
err := cmd.Start()
require.NoError(t, err)

cancel()
err := cmd.Wait()
err = cmd.Wait()
assert.Error(t, err)
assert.IsType(t, context.Canceled, err)
}

func TestNilContext(t *testing.T) {
assert.Panics(t, func() {
//lint:ignore SA1012 Test for panic
dockerexec.CommandContext(nil, dockerClient, testImage, "cat")
dockerexec.CommandContext(nil, dockerClient, testImage, "cat") //nolint:staticcheck
})
}

Expand Down

0 comments on commit 75f8b6c

Please sign in to comment.