forked from github-release/github-release
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub_test.go
More file actions
52 lines (48 loc) · 1.01 KB
/
Copy pathgithub_test.go
File metadata and controls
52 lines (48 loc) · 1.01 KB
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
44
45
46
47
48
49
50
51
52
package github
import (
"net/url"
"testing"
)
func TestRedactedURL(t *testing.T) {
type testCase struct {
name string
initial *url.URL
expected *url.URL
}
testCases := []testCase{
testCase{
name: "without access_token query",
initial: &url.URL{
Host: "example.com",
Scheme: "https",
RawQuery: "foo=bar",
},
expected: &url.URL{
Host: "example.com",
Scheme: "https",
RawQuery: "foo=bar",
},
},
testCase{
name: "with access_token query",
initial: &url.URL{
Host: "example.com",
Scheme: "https",
RawQuery: "access_token=secret&foo=bar",
},
expected: &url.URL{
Host: "example.com",
Scheme: "https",
RawQuery: "access_token=REDACTED&foo=bar",
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
gotURL := redactedURL(tc.initial)
if tc.expected.String() != gotURL.String() {
t.Fatalf("URLs do not match; want: %s, got %s", tc.expected.String(), gotURL.String())
}
})
}
}