summaryrefslogtreecommitdiff
path: root/oblast/internal/testhelpers/must/must.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-09-17 16:21:40 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-09-17 16:21:40 +0200
commit63df99f2e1c742069464d219a9f340c1f8f5bd90 (patch)
treeb64e6742c78e0d7e4bac1d6f3ed8a2c03f2f9c9b /oblast/internal/testhelpers/must/must.go
parentfe37a82d0495a8b59b80677dd42d0d94ffafdfb4 (diff)
downloadgo-gg-63df99f2e1c742069464d219a9f340c1f8f5bd90.tar.gz
oblast: import from go.xyrillian.de/oblast
- type RuntimeIndex is left behind for now because I don't want to commit to the method names yet - the "OrNone" methods are removed in favor of gsql.NoneIfNoRows()
Diffstat (limited to 'oblast/internal/testhelpers/must/must.go')
-rw-r--r--oblast/internal/testhelpers/must/must.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/oblast/internal/testhelpers/must/must.go b/oblast/internal/testhelpers/must/must.go
new file mode 100644
index 0000000..7a137c6
--- /dev/null
+++ b/oblast/internal/testhelpers/must/must.go
@@ -0,0 +1,26 @@
+// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net>
+// SPDX-License-Identifier: Apache-2.0
+
+package must
+
+import "testing"
+
+// Succeed fails the test if err is not nil.
+func Succeed(t testing.TB, err error) {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+}
+
+// Return wraps a function returning two output values,
+// and either forwards the result value on success, or fails the test on error.
+func Return[V any](value V, err error) func(testing.TB) V {
+ return func(t testing.TB) V {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+ return value
+ }
+}