summaryrefslogtreecommitdiff
path: root/internal/test
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-06 16:53:27 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-19 14:15:07 +0100
commitb7e074506446aec8bd1f0ead062d00885a71f043 (patch)
tree0a76dd48dae62c10c3c014a4da4720f1c1eeefa5 /internal/test
parentba538d12e542aa7646468b8492398098623bff9a (diff)
Test: Add an AssertError helper
Diffstat (limited to 'internal/test')
-rw-r--r--internal/test/error.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/test/error.go b/internal/test/error.go
new file mode 100644
index 0000000..98fa09b
--- /dev/null
+++ b/internal/test/error.go
@@ -0,0 +1,16 @@
+package test
+
+import "testing"
+
+func AssertError(t *testing.T, err error, wantErr string) {
+ gv := ""
+ if err != nil {
+ gv = err.Error()
+ }
+ if wantErr != gv {
+ if wantErr == "" {
+ wantErr = "empty string"
+ }
+ t.Fatalf("Errors not equal, got: %v, want: %v", gv, wantErr)
+ }
+}