aboutsummaryrefslogtreecommitdiff
path: root/assert/assert.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-08-18 11:30:54 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-08-18 11:30:54 +0200
commit50ba9cfb04e257fafa3fdd566f9f70a1986339e8 (patch)
treeb4601a46bd2c9b90297e8055bec7d60afc07cdb1 /assert/assert.go
parent22e8f3548a72c78deccedc5a65c1cba029f52e6d (diff)
downloadgo-gg-50ba9cfb04e257fafa3fdd566f9f70a1986339e8.tar.gz
assert: add Panics, PanicsWith
I want to use this for test coverage in microprom. This turned out to be a bigger change than expected because testcapture has a dependency on assert, which I had to invert to be able to use testcapture.Capture() in assert.
Diffstat (limited to 'assert/assert.go')
-rw-r--r--assert/assert.go37
1 files changed, 4 insertions, 33 deletions
diff --git a/assert/assert.go b/assert/assert.go
index a13c15e..fe725f6 100644
--- a/assert/assert.go
+++ b/assert/assert.go
@@ -5,38 +5,9 @@
// Each assertion in this package returns a bool to indicate whether the check succeeded, and logs a t.Error() when the check does not succeed.
package assert
-import (
- "context"
- "io"
- "testing"
-)
+import "go.xyrillian.de/gg/testcapture"
// TestingTB contains all the public functions of [testing.TB] (as of Go 1.26).
-// Functions in this package use this type instead of [testing.TB] because the capture device used by package testcapture cannot implement [testing.TB]: It contains methods that are private to the standard library.
-type TestingTB interface {
- ArtifactDir() string
- Attr(key, value string)
- Chdir(dir string)
- Cleanup(func())
- Context() context.Context
- Error(args ...any)
- Errorf(format string, args ...any)
- Fail()
- Failed() bool
- FailNow()
- Fatal(args ...any)
- Fatalf(format string, args ...any)
- Helper()
- Log(args ...any)
- Logf(format string, args ...any)
- Name() string
- Output() io.Writer
- Setenv(key, value string)
- Skip(args ...any)
- Skipf(format string, args ...any)
- SkipNow()
- Skipped() bool
- TempDir() string
-}
-
-var _ TestingTB = testing.TB(nil)
+// Functions in this package use this type instead of [testing.TB] to allow
+// mocks of [testing.TB] to be substituted in tests for this package.
+type TestingTB = testcapture.TestingTB