Skip to content

Commit

Permalink
client/pkg/testutil: eliminate copyToInterface function
Browse files Browse the repository at this point in the history
AssertTrue and AssertFalse use copyToInterface to copy msg. This is
unnecessary, cause we know the msgAndArgs param of assert.Equal is
variadic:
func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

This patch removes copyToInterface function, and use msg directly.

Signed-off-by: Jes Cok <[email protected]>
  • Loading branch information
callthingsoff committed Mar 30, 2024
1 parent caca515 commit 229ceb3
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions client/pkg/testutil/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ import (
"github.com/stretchr/testify/assert"
)

func copyToInterface(msg ...string) []any {
newMsg := make([]any, len(msg))
for i, v := range msg {
newMsg[i] = v
}
return newMsg
}

func AssertNil(t *testing.T, v any) {
t.Helper()
assert.Nil(t, v)
Expand All @@ -42,12 +34,10 @@ func AssertNotNil(t *testing.T, v any) {

func AssertTrue(t *testing.T, v bool, msg ...string) {
t.Helper()
newMsg := copyToInterface(msg...)
assert.Equal(t, true, v, newMsg)
assert.Equal(t, true, v, msg)
}

func AssertFalse(t *testing.T, v bool, msg ...string) {
t.Helper()
newMsg := copyToInterface(msg...)
assert.Equal(t, false, v, newMsg)
assert.Equal(t, false, v, msg)
}

0 comments on commit 229ceb3

Please sign in to comment.