From 6e7aa1b3fe7db099a1fe5df266348080c26ee5dd Mon Sep 17 00:00:00 2001 From: presbrey Date: Fri, 9 Aug 2024 19:22:42 -0400 Subject: [PATCH] add more client tests --- errors_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/errors_test.go b/errors_test.go index f77c760..06b310d 100644 --- a/errors_test.go +++ b/errors_test.go @@ -39,6 +39,30 @@ func TestAllProxiesUnavailable(t *testing.T) { assert.Equal(t, 2, client.states[1].failureCount) } +func TestClientGetError(t *testing.T) { + config := Config{ + ProxyURLs: []string{"http://10.255.255.1:8080"}, + DialTimeout: 5 * time.Second, + } + + client, err := NewClient(config) + require.NoError(t, err) + _, err = client.Get("\000") + require.Error(t, err) + assert.Contains(t, err.Error(), "invalid control character") +} + +func TestClientNewError(t *testing.T) { + config := Config{ + ProxyURLs: []string{"\000"}, + DialTimeout: 5 * time.Second, + } + + _, err := NewClient(config) + require.Error(t, err) + assert.Contains(t, err.Error(), "invalid control character") +} + func TestClientWithNoProxyURLs(t *testing.T) { config := Config{ ProxyURLs: []string{},