diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-02-26 19:54:48 +0100 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-18 16:30:36 +0200 |
commit | c8e1328164e9ffbd681c3c0e449f1e6b9856b896 (patch) | |
tree | faee639a4c55c5dc3bfc59a5400026822c40221d /pkg/testkit | |
download | lens-c8e1328164e9ffbd681c3c0e449f1e6b9856b896.tar.gz lens-c8e1328164e9ffbd681c3c0e449f1e6b9856b896.tar.bz2 lens-c8e1328164e9ffbd681c3c0e449f1e6b9856b896.zip |
feat: Inicial commit
It contains rough template for the server and runners.
It contains rough template for the server and runners.
Diffstat (limited to 'pkg/testkit')
-rw-r--r-- | pkg/testkit/testkit.go | 31 |
1 files changed, 31 insertions, 0 deletions
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() +} |