MCPcopy Create free account
hub / github.com/aws/aws-lambda-go / TestBinaryResponseDoesNotLeakResources

Function TestBinaryResponseDoesNotLeakResources

lambda/invoke_loop_test.go:330–353  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

328}
329
330func TestBinaryResponseDoesNotLeakResources(t *testing.T) {
331 numResponses := 3
332 responses := make([]*readCloser, numResponses)
333 for i := 0; i < numResponses; i++ {
334 responses[i] = &readCloser{closed: false, reader: strings.NewReader(fmt.Sprintf("hello %d", i))}
335 }
336 timesCalled := 0
337 handler := NewHandler(func() (res io.Reader, _ error) {
338 res = responses[timesCalled]
339 timesCalled++
340 return
341 })
342
343 ts, record := runtimeAPIServer(`{}`, numResponses)
344 defer ts.Close()
345 endpoint := strings.Split(ts.URL, "://")[1]
346 _ = startRuntimeAPILoop(endpoint, handler)
347
348 for i := 0; i < numResponses; i++ {
349 assert.Equal(t, contentTypeBytes, record.contentTypes[i])
350 assert.Equal(t, fmt.Sprintf("hello %d", i), string(record.responses[i]))
351 assert.True(t, responses[i].closed)
352 }
353}
354
355func TestContextDeserializationErrors(t *testing.T) {
356 badClientContext := defaultInvokeMetadata()

Callers

nothing calls this directly

Calls 4

NewHandlerFunction · 0.85
runtimeAPIServerFunction · 0.85
startRuntimeAPILoopFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…