MCPcopy Index your code
hub / github.com/aws/aws-lambda-go / assertPanicMessage

Function assertPanicMessage

lambda/panic_test.go:14–27  ·  view source on GitHub ↗
(t *testing.T, panicFunc func(), expectedMessage string)

Source from the content-addressed store, hash-verified

12)
13
14func assertPanicMessage(t *testing.T, panicFunc func(), expectedMessage string) {
15 defer func() {
16 if err := recover(); err != nil {
17 panicInfo := getPanicInfo(err)
18 assert.NotNil(t, panicInfo)
19 assert.NotNil(t, panicInfo.Message)
20 assert.Equal(t, expectedMessage, panicInfo.Message)
21 assert.NotNil(t, panicInfo.StackTrace)
22 }
23 }()
24
25 panicFunc()
26 t.Errorf("Should have exited due to panic")
27}
28
29func TestPanicFormattingStringValue(t *testing.T) {
30 assertPanicMessage(t, func() { panic("Panic time!") }, "Panic time!")

Calls 1

getPanicInfoFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…