(t *testing.T)
| 409 | } |
| 410 | |
| 411 | func Test_LBClientTransport_StreamResponseBody(t *testing.T) { |
| 412 | t.Parallel() |
| 413 | |
| 414 | t.Run("empty clients", func(t *testing.T) { |
| 415 | t.Parallel() |
| 416 | lbClient := &fasthttp.LBClient{ |
| 417 | Clients: []fasthttp.BalancingClient{}, |
| 418 | } |
| 419 | transport := newLBClientTransport(lbClient) |
| 420 | require.False(t, transport.StreamResponseBody()) |
| 421 | }) |
| 422 | |
| 423 | t.Run("single host client", func(t *testing.T) { |
| 424 | t.Parallel() |
| 425 | hostClient := &fasthttp.HostClient{Addr: "example.com:80"} |
| 426 | lbClient := &fasthttp.LBClient{ |
| 427 | Clients: []fasthttp.BalancingClient{hostClient}, |
| 428 | } |
| 429 | transport := newLBClientTransport(lbClient) |
| 430 | |
| 431 | // Test default |
| 432 | require.False(t, transport.StreamResponseBody()) |
| 433 | |
| 434 | // Enable streaming |
| 435 | transport.SetStreamResponseBody(true) |
| 436 | require.True(t, transport.StreamResponseBody()) |
| 437 | require.True(t, hostClient.StreamResponseBody) |
| 438 | |
| 439 | // Disable streaming |
| 440 | transport.SetStreamResponseBody(false) |
| 441 | require.False(t, transport.StreamResponseBody()) |
| 442 | require.False(t, hostClient.StreamResponseBody) |
| 443 | }) |
| 444 | |
| 445 | t.Run("multiple host clients", func(t *testing.T) { |
| 446 | t.Parallel() |
| 447 | hostClient1 := &fasthttp.HostClient{Addr: "example1.com:80"} |
| 448 | hostClient2 := &fasthttp.HostClient{Addr: "example2.com:80"} |
| 449 | lbClient := &fasthttp.LBClient{ |
| 450 | Clients: []fasthttp.BalancingClient{hostClient1, hostClient2}, |
| 451 | } |
| 452 | transport := newLBClientTransport(lbClient) |
| 453 | |
| 454 | // Enable streaming on all clients |
| 455 | transport.SetStreamResponseBody(true) |
| 456 | require.True(t, transport.StreamResponseBody()) |
| 457 | require.True(t, hostClient1.StreamResponseBody) |
| 458 | require.True(t, hostClient2.StreamResponseBody) |
| 459 | |
| 460 | // Disable streaming on all clients |
| 461 | transport.SetStreamResponseBody(false) |
| 462 | require.False(t, transport.StreamResponseBody()) |
| 463 | require.False(t, hostClient1.StreamResponseBody) |
| 464 | require.False(t, hostClient2.StreamResponseBody) |
| 465 | }) |
| 466 | } |
| 467 | |
| 468 | func Test_httpClientTransport_Interface(t *testing.T) { |
nothing calls this directly
no test coverage detected