(t *testing.T)
| 2439 | } |
| 2440 | |
| 2441 | func Test_Client_StreamResponseBody(t *testing.T) { |
| 2442 | t.Parallel() |
| 2443 | |
| 2444 | t.Run("default value", func(t *testing.T) { |
| 2445 | t.Parallel() |
| 2446 | client := New() |
| 2447 | require.False(t, client.StreamResponseBody()) |
| 2448 | }) |
| 2449 | |
| 2450 | t.Run("enable streaming", func(t *testing.T) { |
| 2451 | t.Parallel() |
| 2452 | client := New() |
| 2453 | result := client.SetStreamResponseBody(true) |
| 2454 | require.True(t, client.StreamResponseBody()) |
| 2455 | require.Equal(t, client, result) |
| 2456 | }) |
| 2457 | |
| 2458 | t.Run("disable streaming", func(t *testing.T) { |
| 2459 | t.Parallel() |
| 2460 | client := New() |
| 2461 | client.SetStreamResponseBody(true) |
| 2462 | require.True(t, client.StreamResponseBody()) |
| 2463 | client.SetStreamResponseBody(false) |
| 2464 | require.False(t, client.StreamResponseBody()) |
| 2465 | }) |
| 2466 | |
| 2467 | t.Run("with host client", func(t *testing.T) { |
| 2468 | t.Parallel() |
| 2469 | hostClient := &fasthttp.HostClient{} |
| 2470 | client := NewWithHostClient(hostClient) |
| 2471 | client.SetStreamResponseBody(true) |
| 2472 | require.True(t, client.StreamResponseBody()) |
| 2473 | require.True(t, hostClient.StreamResponseBody) |
| 2474 | }) |
| 2475 | |
| 2476 | t.Run("with lb client", func(t *testing.T) { |
| 2477 | t.Parallel() |
| 2478 | hostClient := &fasthttp.HostClient{Addr: "example.com:80"} |
| 2479 | lbClient := &fasthttp.LBClient{ |
| 2480 | Clients: []fasthttp.BalancingClient{ |
| 2481 | hostClient, |
| 2482 | }, |
| 2483 | } |
| 2484 | client := NewWithLBClient(lbClient) |
| 2485 | client.SetStreamResponseBody(true) |
| 2486 | require.True(t, client.StreamResponseBody()) |
| 2487 | require.True(t, hostClient.StreamResponseBody) |
| 2488 | }) |
| 2489 | } |
nothing calls this directly
no test coverage detected