From c8e1328164e9ffbd681c3c0e449f1e6b9856b896 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sun, 26 Feb 2023 19:54:48 +0100 Subject: feat: Inicial commit It contains rough template for the server and runners. It contains rough template for the server and runners. --- pkg/testkit/testkit.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pkg/testkit/testkit.go (limited to 'pkg/testkit') diff --git a/pkg/testkit/testkit.go b/pkg/testkit/testkit.go new file mode 100644 index 0000000..526e1b3 --- /dev/null +++ b/pkg/testkit/testkit.go @@ -0,0 +1,31 @@ +//go:build unit || integration + +package testkit + +import ( + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestValue[T any](t *testing.T, method string, want, got T) { + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("%s() mismatch (-want +got):\n%s", method, diff) + } +} + +func TestFatalError(t *testing.T, method string, err error) { + if err != nil { + t.Fatalf("%s() fatal error : %+v", method, err) + } +} + +func TestError(t *testing.T, method string, want, got error) { + if !equalError(want, got) { + t.Errorf("%s() err mismatch want: %+v got %+v", method, want, got) + } +} + +func equalError(a, b error) bool { + return a == nil && b == nil || a != nil && b != nil && a.Error() == b.Error() +} -- cgit v1.2.3