Skip to content

Commit 8049b0d

Browse files
committed
Add test for GHECDataResidencyMatch
1 parent 9e22628 commit 8049b0d

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

github/config_test.go

+58
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,64 @@ import (
77
"github.com/shurcooL/githubv4"
88
)
99

10+
func TestGHECDataResidencyMatch(t *testing.T) {
11+
testCases := []struct {
12+
url string
13+
matches bool
14+
description string
15+
}{
16+
{
17+
url: "https://customer.ghe.com",
18+
matches: true,
19+
description: "GHEC data residency URL with customer name",
20+
},
21+
{
22+
url: "https://customer-name.ghe.com",
23+
matches: true,
24+
description: "GHEC data residency URL with hyphenated name",
25+
},
26+
{
27+
url: "https://api.github.com",
28+
matches: false,
29+
description: "GitHub.com API URL",
30+
},
31+
{
32+
url: "https://github.com",
33+
matches: false,
34+
description: "GitHub.com URL",
35+
},
36+
{
37+
url: "https://example.com",
38+
matches: false,
39+
description: "Generic URL",
40+
},
41+
{
42+
url: "http://customer.ghe.com",
43+
matches: false,
44+
description: "Non-HTTPS GHEC URL",
45+
},
46+
{
47+
url: "https://customer.ghe.com/api/v3",
48+
matches: false,
49+
description: "GHEC URL with path",
50+
},
51+
{
52+
url: "https://ghe.com",
53+
matches: false,
54+
description: "GHEC domain without subdomain",
55+
},
56+
}
57+
58+
for _, tc := range testCases {
59+
t.Run(tc.description, func(t *testing.T) {
60+
matches := GHECDataResidencyMatch.MatchString(tc.url)
61+
if matches != tc.matches {
62+
t.Errorf("URL %q: expected match=%v, got %v", tc.url, tc.matches, matches)
63+
}
64+
})
65+
}
66+
}
67+
1068
func TestAccConfigMeta(t *testing.T) {
1169

1270
// FIXME: Skip test runs during travis lint checking

0 commit comments

Comments
 (0)