Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Sep 16, 2024
1 parent 30571d2 commit 67e9496
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,34 @@ func TestInvoke(t *testing.T) {
)
})
})

t.Run("captures panic stack", func(t *testing.T) {
ctx := context.Background()
r := require.New(t)

a := CreateFunction(
FunctionOpts{Name: "my-fn"},
EventTrigger("my-event", nil),
func(ctx context.Context, event Input[any]) (any, error) {
panic("oh no!")
},
)
Register(a)

actual, op, err := invoke(
ctx, a,
createRequest(t, EventA{Name: "my-event"}),
)
r.Nil(actual)
r.Nil(op)

// Contains the panic message
r.Contains(err.Error(), "oh no!")

// Hacky checks to ensure the stack trace is present
r.Contains(err.Error(), "inngestgo/handler.go")
r.Contains(err.Error(), "inngestgo/handler_test.go")
})
}

func TestServe(t *testing.T) {
Expand Down

0 comments on commit 67e9496

Please sign in to comment.