From e4eb38cd99cfeb076e7e0c284aab5f9f5a017951 Mon Sep 17 00:00:00 2001 From: Kuisong Tong Date: Sun, 12 Nov 2023 19:08:20 -0800 Subject: [PATCH] remove NotEmpty (#54) --- internal/assert/assert.go | 13 ++++--------- provider/env/benchmark_test.go | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/internal/assert/assert.go b/internal/assert/assert.go index 71d573b3..859cda34 100644 --- a/internal/assert/assert.go +++ b/internal/assert/assert.go @@ -27,7 +27,10 @@ func NoError(tb testing.TB, err error) { func EqualError(tb testing.TB, err error, message string) { tb.Helper() - if err.Error() != message { + switch { + case err == nil: + tb.Errorf("expected: %v; actual: ", message) + case err.Error() != message: tb.Errorf("expected: %v; actual: %v", message, err.Error()) } } @@ -39,11 +42,3 @@ func True(tb testing.TB, value bool) { tb.Errorf("expected True") } } - -func NotEmpty(tb testing.TB, value any) { - tb.Helper() - - if reflect.ValueOf(value).IsZero() { - tb.Errorf("expected not empty") - } -} diff --git a/provider/env/benchmark_test.go b/provider/env/benchmark_test.go index 57ff7ef7..1bace988 100644 --- a/provider/env/benchmark_test.go +++ b/provider/env/benchmark_test.go @@ -19,7 +19,7 @@ func BenchmarkNew(b *testing.B) { values, err := loader.Load() assert.NoError(b, err) - assert.NotEmpty(b, values["USER"]) + assert.True(b, values["USER"] != "") } func BenchmarkLoad(b *testing.B) { @@ -36,5 +36,5 @@ func BenchmarkLoad(b *testing.B) { b.StopTimer() assert.NoError(b, err) - assert.NotEmpty(b, values["USER"]) + assert.True(b, values["USER"] != "") }