influxdb/influxql/query_request_test.go

29 lines
686 B
Go
Raw Normal View History

package influxql
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEncodingFormatFromMimeType(t *testing.T) {
tests := []struct {
2021-01-29 16:50:57 +00:00
s string
exp EncodingFormat
}{
{s: "application/csv", exp: EncodingFormatAppCSV},
{s: "text/csv", exp: EncodingFormatTextCSV},
{s: "application/x-msgpack", exp: EncodingFormatMessagePack},
{s: "application/json", exp: EncodingFormatJSON},
{s: "*/*", exp: EncodingFormatJSON},
{s: "", exp: EncodingFormatJSON},
{s: "application/other", exp: EncodingFormatJSON},
}
for _, tt := range tests {
t.Run(tt.s, func(t *testing.T) {
got := EncodingFormatFromMimeType(tt.s)
assert.Equal(t, tt.exp, got)
})
}
}