From 229ceb3a73e3547674dd638cc014324514ea5ad6 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Sat, 30 Mar 2024 23:59:07 +0800 Subject: [PATCH] client/pkg/testutil: eliminate copyToInterface function 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 --- client/pkg/testutil/assert.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/client/pkg/testutil/assert.go b/client/pkg/testutil/assert.go index 88e674b8d76..4e23e4e7e28 100644 --- a/client/pkg/testutil/assert.go +++ b/client/pkg/testutil/assert.go @@ -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) @@ -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) }