-
Notifications
You must be signed in to change notification settings - Fork 3
/
regex_test.go
43 lines (39 loc) · 1.19 KB
/
regex_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 main
import "testing"
func TestIsMatchRepoDescription(t *testing.T) {
repoRegex := "[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+"
publicRegex := repoRegex + "/0/[01]/[01]"
privateRegex := repoRegex + "/1/[01]/[01]"
t.Log(publicRegex)
t.Log(privateRegex)
publicCases := map[string]bool{
"tbxark/backup/0/0/0": true,
"tbxark/backup/0/0/1": true,
"tbxark/backup/0/1/0": true,
"tbxark/backup/0/1/1": true,
"tbxark-arc/backup/0/0/0": true,
"tbxark-arc/backup/0/0/1": true,
"tbxark-arc/backup/0/1/0": true,
"tbxark-arc/backup/0/1/1": true,
}
privateCases := map[string]bool{
"tbxark/backup/1/0/0": true,
"tbxark/backup/1/0/1": true,
"tbxark/backup/1/1/0": true,
"tbxark/backup/1/1/1": true,
"tbxark-arc/backup-arc/1/0/0": true,
"tbxark-arc/backup-arc/1/0/1": true,
"tbxark-arc/backup-arc/1/1/0": true,
"tbxark-arc/backup-arc/1/1/1": true,
}
for c, v := range publicCases {
if !IsMatchRepoIdentity(c, publicRegex) {
t.Errorf("public case %s expect %v but %v", c, v, false)
}
}
for c, v := range privateCases {
if !IsMatchRepoIdentity(c, privateRegex) {
t.Errorf("private case %s expect %v but %v", c, v, false)
}
}
}