From 50ba9cfb04e257fafa3fdd566f9f70a1986339e8 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Tue, 18 Aug 2026 11:30:54 +0200 Subject: 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. --- assert/errequal_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'assert/errequal_test.go') diff --git a/assert/errequal_test.go b/assert/errequal_test.go index b97342a..2cefeab 100644 --- a/assert/errequal_test.go +++ b/assert/errequal_test.go @@ -11,7 +11,6 @@ import ( "testing" "go.xyrillian.de/gg/assert" - "go.xyrillian.de/gg/testcapture" ) func TestErrEqual(t *testing.T) { @@ -67,13 +66,10 @@ func TestErrEqual(t *testing.T) { }, `expected an error matching /foo/, but got no error`) // test matching against unexpected type - result := testcapture.Capture(t.Context(), t.Name(), func(t assert.TestingTB) { + result := assert.PanicsWith[string](t, func() { assert.ErrEqual(t, errors.New("42"), 42) }) - assert.Equal(t, result, testcapture.Result{ - Outcome: testcapture.OutcomePanicked, - Panic: "cannot handle `expected` of type int", - }) + assert.Equal(t, result, "cannot handle `expected` of type int") // an earlier version had a bug because this call caused reflect.Value.IsNil() to be called on a value of kind Struct expectErrors(t, func(t assert.TestingTB) { -- cgit v1.3.1