summaryrefslogtreecommitdiff
path: root/modules/proxy/proxy_test.go
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2024-01-10 21:06:43 +0100
committerGitHub <noreply@github.com>2024-01-10 21:06:43 +0100
commit8ad9f9f66af1452b1a4875d755e7f18154c3f18a (patch)
tree4a8d68513e71c44d121b11093094238a31e03daf /modules/proxy/proxy_test.go
parent8b7425e58909cdfa458ca00a10efc95f197bfb0b (diff)
Add single proxy support (#30)
* Add single proxy config option * Update readme
Diffstat (limited to 'modules/proxy/proxy_test.go')
-rw-r--r--modules/proxy/proxy_test.go11
1 files changed, 7 insertions, 4 deletions
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 {