Skip to content

Commit 1650763

Browse files
committed
cover RequestFromContext
1 parent 787a3c2 commit 1650763

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lambdaurl/http_handler_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,16 @@ func TestWrap(t *testing.T) {
142142
})
143143
}
144144
}
145+
146+
func TestRequestContext(t *testing.T) {
147+
var req *events.LambdaFunctionURLRequest
148+
require.NoError(t, json.Unmarshal(helloRequest, &req))
149+
handler := Wrap(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
150+
reqFromContext, exists := RequestFromContext(r.Context())
151+
require.True(t, exists)
152+
require.NotNil(t, reqFromContext)
153+
assert.Equal(t, req, reqFromContext)
154+
}))
155+
_, err := handler(context.Background(), req)
156+
require.NoError(t, err)
157+
}

0 commit comments

Comments
 (0)