@@ -7,6 +7,64 @@ import (
7
7
"github.com/shurcooL/githubv4"
8
8
)
9
9
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
+
10
68
func TestAccConfigMeta (t * testing.T ) {
11
69
12
70
// FIXME: Skip test runs during travis lint checking
0 commit comments