-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcategorize_test.go
56 lines (38 loc) · 1.21 KB
/
categorize_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
package templar
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektra/neko"
)
func TestCategorize(t *testing.T) {
n := neko.Start(t)
n.It("indicates that a GET is stateless", func() {
req, err := http.NewRequest("GET", "http://google.com/foo/bar", nil)
require.NoError(t, err)
cat := NewCategorizer()
assert.True(t, cat.Stateless(req))
})
n.It("indicates that a POST is not stateless", func() {
req, err := http.NewRequest("POST", "http://google.com/foo/bar", nil)
require.NoError(t, err)
cat := NewCategorizer()
assert.False(t, cat.Stateless(req))
})
n.It("honors a header to override behavior on be stateful", func() {
req, err := http.NewRequest("GET", "http://google.com/foo/bar", nil)
require.NoError(t, err)
req.Header.Add(CategoryHeader, "stateful")
cat := NewCategorizer()
assert.False(t, cat.Stateless(req))
})
n.It("honors a header to override behavior to be stateless", func() {
req, err := http.NewRequest("POST", "http://google.com/foo/bar", nil)
require.NoError(t, err)
req.Header.Add(CategoryHeader, "stateless")
cat := NewCategorizer()
assert.True(t, cat.Stateless(req))
})
n.Meow()
}