From 8ad9f9f66af1452b1a4875d755e7f18154c3f18a Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Wed, 10 Jan 2024 21:06:43 +0100 Subject: Add single proxy support (#30) * Add single proxy config option * Update readme --- modules/proxy/proxy_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'modules/proxy/proxy_test.go') diff --git a/modules/proxy/proxy_test.go b/modules/proxy/proxy_test.go index 62da23a..219649e 100644 --- a/modules/proxy/proxy_test.go +++ b/modules/proxy/proxy_test.go @@ -35,19 +35,21 @@ func TestProxy(t *testing.T) { } func TestProxyMultiple(t *testing.T) { - calls := []int{0, 0} + calls := []int{0, 0, 0} p0 := newProxy(func() { calls[0]++ }) p1 := newProxy(func() { calls[1]++ }) + p2 := newProxy(func() { calls[2]++ }) defer p0.Close() defer p1.Close() + defer p2.Close() - mod := &proxy.Module{Proxies: []string{p0.URL, p1.URL}} + mod := &proxy.Module{Proxies: []string{p0.URL, p1.URL}, Proxy: p2.URL} mod.Provision(nil) trans := mod.AdaptTransport(nil) req := httptest.NewRequest("GET", "http://www.example.com/", nil) - for i := 0; i < 10; i++ { + for i := 0; i < 50; i++ { resp, err := trans.RoundTrip(req) require.NoError(t, err) require.Equal(t, http.StatusOK, resp.StatusCode) @@ -55,7 +57,8 @@ func TestProxyMultiple(t *testing.T) { require.Greater(t, calls[0], 1) require.Greater(t, calls[1], 1) - require.Equal(t, 10, calls[0]+calls[1]) + require.Greater(t, calls[2], 1) + require.Equal(t, 50, calls[0]+calls[1]+calls[2]) } func newProxy(f func()) *httptest.Server { -- cgit v1.2.3