aboutsummaryrefslogtreecommitdiff
path: root/internal/testhelpers/must
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-04-24 15:46:24 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-04-24 16:10:09 +0200
commite45a8be0dcfc375963a061d83e04429995053da1 (patch)
tree55a5f39180be3d289ccbd1f406022d3a72c13034 /internal/testhelpers/must
parent027641ef9efec9ed5dfc463d9c2f38c32716d9b5 (diff)
downloadgo-oblast-e45a8be0dcfc375963a061d83e04429995053da1.tar.gz
exclude testhelpers from coverage testing
Diffstat (limited to 'internal/testhelpers/must')
-rw-r--r--internal/testhelpers/must/must.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/testhelpers/must/must.go b/internal/testhelpers/must/must.go
new file mode 100644
index 0000000..7a137c6
--- /dev/null
+++ b/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
+ }
+}