Skip to content

Commit 9d1aa99

Browse files
committed
add test
1 parent c611125 commit 9d1aa99

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package connectors
2+
3+
import (
4+
"errors"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
type testRPCURLConnector struct {
11+
*mockConnectorForPoller
12+
rpcURL string
13+
}
14+
15+
func (t *testRPCURLConnector) RPCURL() string {
16+
return t.rpcURL
17+
}
18+
19+
func TestSafeConnectorErrorForLogging(t *testing.T) {
20+
rawURL := "https://user:pass@example.com/path?api_key=secret"
21+
err := errors.New("request failed for " + rawURL)
22+
23+
assert.Equal(t, "", safeConnectorErrorForLogging(nil, &mockConnectorForPoller{}))
24+
assert.Equal(t, err.Error(), safeConnectorErrorForLogging(err, &mockConnectorForPoller{}))
25+
26+
connector := &testRPCURLConnector{
27+
mockConnectorForPoller: &mockConnectorForPoller{},
28+
rpcURL: rawURL,
29+
}
30+
assert.Equal(t, "request failed for example.com", safeConnectorErrorForLogging(err, connector))
31+
}

0 commit comments

Comments
 (0)