(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func TestIsProxySocketError(t *testing.T) { |
| 64 | t.Parallel() |
| 65 | |
| 66 | tests := []struct { |
| 67 | name string |
| 68 | errStr string |
| 69 | expected bool |
| 70 | }{ |
| 71 | { |
| 72 | name: "no such file or directory", |
| 73 | errStr: "proxyconnect tcp: dial unix /path/to/httpproxy.sock: connect: no such file or directory", |
| 74 | expected: true, |
| 75 | }, |
| 76 | { |
| 77 | name: "connection refused", |
| 78 | errStr: "proxyconnect tcp: dial unix /path/to/httpproxy.sock: connect: connection refused", |
| 79 | expected: true, |
| 80 | }, |
| 81 | { |
| 82 | name: "proxyconnect tcp error", |
| 83 | errStr: "Post https://api.anthropic.com/v1/messages: proxyconnect tcp: some error", |
| 84 | expected: true, |
| 85 | }, |
| 86 | { |
| 87 | name: "dial unix error", |
| 88 | errStr: "dial unix /var/run/docker.sock: operation timed out", |
| 89 | expected: true, |
| 90 | }, |
| 91 | { |
| 92 | name: "regular network error", |
| 93 | errStr: "dial tcp 192.168.1.1:443: i/o timeout", |
| 94 | expected: false, |
| 95 | }, |
| 96 | { |
| 97 | name: "HTTP error", |
| 98 | errStr: "HTTP 500: internal server error", |
| 99 | expected: false, |
| 100 | }, |
| 101 | { |
| 102 | name: "nil error", |
| 103 | errStr: "", |
| 104 | expected: false, |
| 105 | }, |
| 106 | } |
| 107 | |
| 108 | for _, tc := range tests { |
| 109 | t.Run(tc.name, func(t *testing.T) { |
| 110 | t.Parallel() |
| 111 | var err error |
| 112 | if tc.errStr != "" { |
| 113 | err = &testError{msg: tc.errStr} |
| 114 | } |
| 115 | result := isProxySocketError(err) |
| 116 | assert.Equal(t, tc.expected, result) |
| 117 | }) |
| 118 | } |
| 119 | } |
| 120 |
nothing calls this directly
no test coverage detected