etcd/client/pkg/testutil/assert.go
Jes Cok 229ceb3a73 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 <xigua67damn@gmail.com>
2024-03-30 23:59:07 +08:00

44 lines
1.0 KiB
Go

// Copyright 2017 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package testutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func AssertNil(t *testing.T, v any) {
t.Helper()
assert.Nil(t, v)
}
func AssertNotNil(t *testing.T, v any) {
t.Helper()
if v == nil {
t.Fatalf("expected non-nil, got %+v", v)
}
}
func AssertTrue(t *testing.T, v bool, msg ...string) {
t.Helper()
assert.Equal(t, true, v, msg)
}
func AssertFalse(t *testing.T, v bool, msg ...string) {
t.Helper()
assert.Equal(t, false, v, msg)
}