-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmethods_test.go
54 lines (46 loc) · 1.04 KB
/
methods_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
package gimlet
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMethodString(t *testing.T) {
assert := assert.New(t)
cases := map[httpMethod]string{
get: "GET",
put: "PUT",
del: "DELETE",
patch: "PATCH",
post: "POST",
head: "HEAD",
httpMethod(100): "",
httpMethod(50): "",
}
for meth, out := range cases {
assert.Equal(out, meth.String())
}
}
func TestOutputFormat(t *testing.T) {
assert := assert.New(t)
cases := map[OutputFormat]string{
JSON: "json",
TEXT: "text",
HTML: "html",
YAML: "yaml",
BINARY: "binary",
}
for meth, out := range cases {
assert.Equal(out, meth.String())
assert.True(meth.IsValid())
}
cases = map[OutputFormat]string{
OutputFormat(500): "text",
OutputFormat(50): "text",
}
for meth, out := range cases {
assert.Equal(out, meth.String())
assert.False(meth.IsValid())
}
// content-type should default to text
assert.Equal(OutputFormat(100).ContentType(),
TEXT.ContentType())
}