From 16507632ab5f01946eb23fbd4741c9b2eab8c0fb Mon Sep 17 00:00:00 2001 From: Bryan Moffatt Date: Sun, 23 Apr 2023 15:24:04 -0700 Subject: [PATCH] cover RequestFromContext --- lambdaurl/http_handler_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lambdaurl/http_handler_test.go b/lambdaurl/http_handler_test.go index 5ade8436..a6e6aa8d 100644 --- a/lambdaurl/http_handler_test.go +++ b/lambdaurl/http_handler_test.go @@ -142,3 +142,16 @@ func TestWrap(t *testing.T) { }) } } + +func TestRequestContext(t *testing.T) { + var req *events.LambdaFunctionURLRequest + require.NoError(t, json.Unmarshal(helloRequest, &req)) + handler := Wrap(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + reqFromContext, exists := RequestFromContext(r.Context()) + require.True(t, exists) + require.NotNil(t, reqFromContext) + assert.Equal(t, req, reqFromContext) + })) + _, err := handler(context.Background(), req) + require.NoError(t, err) +}