forked from beme/abide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assert_test.go
29 lines (25 loc) · 880 Bytes
/
assert_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
package abide
import (
"testing"
)
func TestContentTypeIsJSON(test *testing.T) {
contentTypeTestCases := map[string]bool{
"application/json": true,
"application/json; charset=utf-8": true,
"application/vnd.foo.bar.v2+json": true,
"application/application/json": false,
"application/json/json": false,
"application/jsoner; charset=utf-8": false,
"application/jsoner": false,
"application/vnd.foo.bar.v2+jsoner": false,
"application/xml": false,
"text/html": false,
"": false,
}
for input, expectedOutput := range contentTypeTestCases {
result := contentTypeIsJSON(input)
if result != expectedOutput {
test.Errorf("contentTypeIsJSON(\"%s\" unexpected result. Got=%t, Want=%t", input, result, expectedOutput)
}
}
}