forked from lox/httpcache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcachecontrol_test.go
More file actions
47 lines (42 loc) · 1.01 KB
/
cachecontrol_test.go
File metadata and controls
47 lines (42 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
package httpcache_test
import (
"testing"
. "github.com/lox/httpcache"
"github.com/stretchr/testify/require"
)
func TestParsingCacheControl(t *testing.T) {
table := []struct {
ccString string
ccStruct CacheControl
}{
{`public, private="set-cookie", max-age=100`, CacheControl{
"public": []string{},
"private": []string{"set-cookie"},
"max-age": []string{"100"},
}},
{` foo="max-age=8, space", public`, CacheControl{
"public": []string{},
"foo": []string{"max-age=8, space"},
}},
{`s-maxage=86400`, CacheControl{
"s-maxage": []string{"86400"},
}},
{`max-stale`, CacheControl{
"max-stale": []string{},
}},
{`max-stale=60`, CacheControl{
"max-stale": []string{"60"},
}},
{`" max-age=8,max-age=8 "=blah`, CacheControl{
" max-age=8,max-age=8 ": []string{"blah"},
}},
}
for _, expect := range table {
cc, err := ParseCacheControl(expect.ccString)
if err != nil {
t.Fatal(err)
}
require.Equal(t, cc, expect.ccStruct)
require.NotEmpty(t, cc.String())
}
}