forked from nokia/restful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contenttype_test.go
35 lines (29 loc) · 906 Bytes
/
contenttype_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
// Copyright 2021 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause
package restful
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBaseContentType(t *testing.T) {
assert := assert.New(t)
inputTable := []struct {
expected string
input string
}{
{ContentTypeApplicationJSON, "application/json"},
{ContentTypeApplicationJSON, "application/JSON"},
{ContentTypeApplicationJSON, "aPpLiCaTiOn/JsOn"},
{ContentTypeApplicationJSON, "application/json;charset=ISO-8859-1"},
{ContentTypeProblemJSON, "application/problem+JSON"},
{ContentTypePatchJSON, "application/json-patch+json"},
{ContentTypeMergeJSON, "application/merge-patch+json;hello"},
{"whatever/contenttype", "whatEVER/ContentType"},
{"", ""},
{"", ";"},
}
for _, test := range inputTable {
assert.Equal(test.expected, BaseContentType(test.input))
}
}