MCPcopy Index your code
hub / github.com/aws/aws-lambda-go / TestReadPayload

Function TestReadPayload

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

Source from the content-addressed store, hash-verified

278}
279
280func TestReadPayload(t *testing.T) {
281 ts, record := runtimeAPIServer(`{"message": "I am craving tacos"}`, 1)
282 defer ts.Close()
283
284 handler := NewHandler(func(event struct{ Message string }) (string, error) {
285 length := utf8.RuneCountInString(event.Message)
286 reversed := make([]rune, length)
287 for i, v := range event.Message {
288 reversed[length-i-1] = v
289 }
290 return string(reversed), nil
291 })
292 endpoint := strings.Split(ts.URL, "://")[1]
293 _ = startRuntimeAPILoop(endpoint, handler)
294 assert.Equal(t, `"socat gnivarc ma I"`, string(record.responses[0]))
295 assert.Equal(t, contentTypeJSON, record.contentTypes[0])
296}
297
298type readCloser struct {
299 closed bool

Callers

nothing calls this directly

Calls 4

runtimeAPIServerFunction · 0.85
NewHandlerFunction · 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…