lens @ a9a270ba1e1e9add10d75de3e592efee9728c5b4

 1//go:build unit || integration
 2
 3package testkit
 4
 5import (
 6	"testing"
 7
 8	"github.com/google/go-cmp/cmp"
 9)
10
11func TestValue[T any](t *testing.T, method string, want, got T) {
12	t.Helper()
13	if diff := cmp.Diff(want, got); diff != "" {
14		t.Errorf("%s() mismatch (-want +got):\n%s", method, diff)
15	}
16}
17
18func TestFatalError(t *testing.T, method string, err error) {
19	t.Helper()
20	if err != nil {
21		t.Fatalf("%s() fatal error : %+v", method, err)
22	}
23}
24
25func TestError(t *testing.T, method string, want, got error) {
26	t.Helper()
27	if !equalError(want, got) {
28		t.Errorf("%s() err mismatch want: %+v got %+v", method, want, got)
29	}
30}
31
32func equalError(a, b error) bool {
33	return a == nil && b == nil || a != nil && b != nil && a.Error() == b.Error()
34}