forked from rqlite/gorqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.go
43 lines (40 loc) · 866 Bytes
/
api_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gorqlite
import (
"testing"
)
func Test_RedactURL(t *testing.T) {
tests := []struct {
name string
url string
want string
}{
{
name: "no credentials",
url: "http://localhost:4001/db/query",
want: "http://localhost:4001/db/query",
},
{
name: "with credentials",
url: "http://user:pass@localhost:4001/db/query",
want: "http://user:xxxxx@localhost:4001/db/query",
},
{
name: "with credentials and params",
url: "http://user:notasecret@localhost:4001/db/query?pretty=true",
want: "http://user:xxxxx@localhost:4001/db/query?pretty=true",
},
{
name: "invalid url",
url: "h{tp://invalid-url",
want: "",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := redactURL(test.url)
if got != test.want {
t.Errorf("got %s, want %s", got, test.want)
}
})
}
}