(t *testing.T)
| 328 | } |
| 329 | |
| 330 | func 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 | |
| 355 | func TestContextDeserializationErrors(t *testing.T) { |
| 356 | badClientContext := defaultInvokeMetadata() |
nothing calls this directly
no test coverage detected
searching dependent graphs…