all repos — gomponents @ f316a0a1fe7dd4445c4ae36db7e2764fdcf8e066

HTML components in pure Go

Fix attr panic test (#222)

It didn't actually work the way it was written.
Markus Wüstenberg markus@maragu.dk
Wed, 09 Oct 2024 10:48:52 +0200
commit

f316a0a1fe7dd4445c4ae36db7e2764fdcf8e066

parent

52357fc500662a01f72b9c7ae5b016a68a5c1da1

1 files changed, 2 insertions(+), 6 deletions(-)

jump to
M gomponents_test.gogomponents_test.go
@@ -36,16 +36,12 @@ assert.Equal(t, ` id="hat"`, a) 	})
 
 	t.Run("panics with more than two arguments", func(t *testing.T) {
-		called := false
 		defer func() {
-			if err := recover(); err != nil {
-				called = true
+			if rec := recover(); rec == nil {
+				t.FailNow()
 			}
 		}()
 		g.Attr("name", "value", "what is this?")
-		if !called {
-			t.FailNow()
-		}
 	})
 
 	t.Run("implements fmt.Stringer", func(t *testing.T) {