@@ -232,6 +232,61 @@ func TestEventWebRequest(t *testing.T) {
232232 urlString : "//:3000/the/path" ,
233233 transport : newrelic .TransportHTTP ,
234234 },
235+
236+ {
237+ testname : "empty LambdaFunctionURLRequest" ,
238+ input : events.LambdaFunctionURLRequest {},
239+ numHeaders : 0 ,
240+ method : "" ,
241+ urlString : "" ,
242+ transport : newrelic .TransportUnknown ,
243+ },
244+ {
245+ testname : "populated LambdaFunctionURLRequest" ,
246+ input : events.LambdaFunctionURLRequest {
247+ Headers : map [string ]string {
248+ "x-forwarded-port" : "3000" ,
249+ "x-forwarded-proto" : "HttP" ,
250+ },
251+ RequestContext : events.LambdaFunctionURLRequestContext {
252+ HTTP : events.LambdaFunctionURLRequestContextHTTPDescription {
253+ Method : "GET" ,
254+ },
255+ },
256+ RawPath : "the/path" ,
257+ },
258+ numHeaders : 2 ,
259+ method : "GET" ,
260+ urlString : "//:3000/the/path" ,
261+ transport : newrelic .TransportHTTP ,
262+ },
263+ {
264+ testname : "nil *LambdaFunctionURLRequest" ,
265+ input : (* events .LambdaFunctionURLRequest )(nil ),
266+ numHeaders : 0 ,
267+ method : "" ,
268+ urlString : "" ,
269+ transport : newrelic .TransportUnknown ,
270+ },
271+ {
272+ testname : "populated *LambdaFunctionURLRequest" ,
273+ input : & events.LambdaFunctionURLRequest {
274+ Headers : map [string ]string {
275+ "x-forwarded-port" : "3000" ,
276+ "x-forwarded-proto" : "HttP" ,
277+ },
278+ RequestContext : events.LambdaFunctionURLRequestContext {
279+ HTTP : events.LambdaFunctionURLRequestContextHTTPDescription {
280+ Method : "GET" ,
281+ },
282+ },
283+ RawPath : "the/path" ,
284+ },
285+ numHeaders : 2 ,
286+ method : "GET" ,
287+ urlString : "//:3000/the/path" ,
288+ transport : newrelic .TransportHTTP ,
289+ },
235290 }
236291
237292 for _ , tc := range testcases {
@@ -422,4 +477,110 @@ func TestEventResponse(t *testing.T) {
422477 })
423478 }
424479 })
480+
481+ t .Run ("LambdaFunctionURLResponse" , func (t * testing.T ) {
482+ t .Run ("empty" , func (t * testing.T ) {
483+ input := events.LambdaFunctionURLResponse {}
484+ runTest (t , input , & response {
485+ header : http.Header {},
486+ code : 0 ,
487+ })
488+ })
489+
490+ for _ , tc := range testcases {
491+ if len (tc .multiValueHeaders ) > 0 {
492+ // LambdaFunctionURLResponse does not currently support multi-value headers
493+ continue
494+ }
495+ t .Run (tc .testname , func (t * testing.T ) {
496+ input := events.LambdaFunctionURLResponse {
497+ StatusCode : 200 ,
498+ Headers : tc .headers ,
499+ }
500+ runTest (t , input , & response {
501+ header : tc .wantHeaders ,
502+ code : 200 ,
503+ })
504+ })
505+ }
506+ })
507+ t .Run ("*LambdaFunctionURLResponse" , func (t * testing.T ) {
508+ t .Run ("nil" , func (t * testing.T ) {
509+ input := (* events .LambdaFunctionURLResponse )(nil )
510+ runTest (t , input , & response {
511+ header : http.Header {},
512+ code : 0 ,
513+ })
514+ })
515+
516+ for _ , tc := range testcases {
517+ if len (tc .multiValueHeaders ) > 0 {
518+ // LambdaFunctionURLResponse does not currently support multi-value headers
519+ continue
520+ }
521+ t .Run (tc .testname , func (t * testing.T ) {
522+ input := & events.LambdaFunctionURLResponse {
523+ StatusCode : 200 ,
524+ Headers : tc .headers ,
525+ }
526+ runTest (t , input , & response {
527+ header : tc .wantHeaders ,
528+ code : 200 ,
529+ })
530+ })
531+ }
532+ })
533+
534+ t .Run ("LambdaFunctionURLStreamingResponse" , func (t * testing.T ) {
535+ t .Run ("empty" , func (t * testing.T ) {
536+ input := events.LambdaFunctionURLStreamingResponse {}
537+ runTest (t , input , & response {
538+ header : http.Header {},
539+ code : 0 ,
540+ })
541+ })
542+
543+ for _ , tc := range testcases {
544+ if len (tc .multiValueHeaders ) > 0 {
545+ // LambdaFunctionURLStreamingResponse does not currently support multi-value headers
546+ continue
547+ }
548+ t .Run (tc .testname , func (t * testing.T ) {
549+ input := events.LambdaFunctionURLStreamingResponse {
550+ StatusCode : 200 ,
551+ Headers : tc .headers ,
552+ }
553+ runTest (t , input , & response {
554+ header : tc .wantHeaders ,
555+ code : 200 ,
556+ })
557+ })
558+ }
559+ })
560+ t .Run ("*LambdaFunctionURLStreamingResponse" , func (t * testing.T ) {
561+ t .Run ("nil" , func (t * testing.T ) {
562+ input := (* events .LambdaFunctionURLStreamingResponse )(nil )
563+ runTest (t , input , & response {
564+ header : http.Header {},
565+ code : 0 ,
566+ })
567+ })
568+
569+ for _ , tc := range testcases {
570+ if len (tc .multiValueHeaders ) > 0 {
571+ // LambdaFunctionURLStreamingResponse does not currently support multi-value headers
572+ continue
573+ }
574+ t .Run (tc .testname , func (t * testing.T ) {
575+ input := & events.LambdaFunctionURLStreamingResponse {
576+ StatusCode : 200 ,
577+ Headers : tc .headers ,
578+ }
579+ runTest (t , input , & response {
580+ header : tc .wantHeaders ,
581+ code : 200 ,
582+ })
583+ })
584+ }
585+ })
425586}
0 commit comments