forked from traefik/seo-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_test.go
77 lines (71 loc) · 1.77 KB
/
core_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"regexp"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_shouldProcessFile(t *testing.T) {
testCases := []struct {
desc string
filePath string
includePattern *regexp.Regexp
expected bool
}{
{
desc: "match html file",
filePath: "index.html",
includePattern: htmlFileRegex,
expected: true,
},
{
desc: "does not match html file",
filePath: "index.htm",
includePattern: htmlFileRegex,
expected: false,
},
{
desc: "match html file under version",
filePath: "/v2.4/index.html",
includePattern: htmlFileRegex,
expected: true,
},
{
desc: "does not match html file under version",
filePath: "/v2.4/index.htm",
includePattern: htmlFileRegex,
expected: false,
},
{
desc: "match sitemap under version",
filePath: "foo/v2.4/sitemap.xml",
includePattern: sitemapUnderVersionRegex,
expected: true,
},
{
desc: "match sitemap under version",
filePath: "foo/v2.4/sitemap.xml.gz",
includePattern: sitemapUnderVersionRegex,
expected: true,
},
{
desc: "does not match sitemap under version",
filePath: "foo/v2.4/powpow.xml.gz",
includePattern: sitemapUnderVersionRegex,
expected: false,
},
{
desc: "does not match sitemap under version",
filePath: "/powpow.xml.gz",
includePattern: sitemapUnderVersionRegex,
expected: false,
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
match := shouldProcessFile(test.filePath, test.includePattern)
assert.Equal(t, test.expected, match)
})
}
}