Skip to content

Commit

Permalink
Cleanup some assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <[email protected]>
  • Loading branch information
dnephin committed Mar 16, 2018
1 parent 073963e commit ef01dea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 2 additions & 0 deletions daemon/logger/awslogs/cloudwatchlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type logStream struct {
sequenceToken *string
}

var _ logger.SizedLogger = &logStream{}

type api interface {
CreateLogGroup(*cloudwatchlogs.CreateLogGroupInput) (*cloudwatchlogs.CreateLogGroupOutput, error)
CreateLogStream(*cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error)
Expand Down
8 changes: 1 addition & 7 deletions daemon/logger/awslogs/cloudwatchlogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,6 @@ func TestCreateTagSuccess(t *testing.T) {
}
}

func TestIsSizedLogger(t *testing.T) {
awslogs := &logStream{}
assert.Implements(t, (*logger.SizedLogger)(nil), awslogs, "awslogs should implement SizedLogger")
}

func BenchmarkUnwrapEvents(b *testing.B) {
events := make([]wrappedEvent, maximumLogEventsPerPut)
for i := 0; i < maximumLogEventsPerPut; i++ {
Expand All @@ -1157,11 +1152,10 @@ func BenchmarkUnwrapEvents(b *testing.B) {
}
}

as := assert.New(b)
b.ResetTimer()
for i := 0; i < b.N; i++ {
res := unwrapEvents(events)
as.Len(res, maximumLogEventsPerPut)
assert.Len(b, res, maximumLogEventsPerPut)
}
}

Expand Down
13 changes: 5 additions & 8 deletions pkg/term/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package term // import "github.com/docker/docker/pkg/term"
import (
"bytes"
"fmt"
"reflect"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand All @@ -25,7 +25,8 @@ func TestEscapeProxyRead(t *testing.T) {
nr, err = reader.Read(buf)
require.Error(t, err, "Should throw error when no keys are to read")
require.EqualValues(t, nr, 0, "nr should be zero")
require.Condition(t, func() (success bool) { return len(keys) == 0 && len(buf) == 0 }, "keys & the read buffer size should be zero")
assert.Len(t, keys, 0)
assert.Len(t, buf, 0)

escapeKeys, _ = ToBytes("ctrl-x,ctrl-@")
keys, _ = ToBytes("DEL")
Expand All @@ -41,9 +42,7 @@ func TestEscapeProxyRead(t *testing.T) {
reader = NewEscapeProxy(bytes.NewReader(keys), escapeKeys)
buf = make([]byte, len(keys))
nr, err = reader.Read(buf)
require.Condition(t, func() (success bool) {
return reflect.TypeOf(err).Name() == "EscapeError"
}, err)
require.EqualError(t, err, "read escape sequence")
require.EqualValues(t, nr, 0, "nr should be equal to 0")
require.Equal(t, keys, buf, "keys & the read buffer should be equal")

Expand All @@ -56,9 +55,7 @@ func TestEscapeProxyRead(t *testing.T) {
require.EqualValues(t, nr, 0, "nr should be equal to 0")
require.Equal(t, keys[0:1], buf, "keys & the read buffer should be equal")
nr, err = reader.Read(buf)
require.Condition(t, func() (success bool) {
return reflect.TypeOf(err).Name() == "EscapeError"
}, err)
require.EqualError(t, err, "read escape sequence")
require.EqualValues(t, nr, 0, "nr should be equal to 0")
require.Equal(t, keys[1:], buf, "keys & the read buffer should be equal")

Expand Down

0 comments on commit ef01dea

Please sign in to comment.