hugo-micropub/validation_test.go

26 lines
606 B
Go
Raw Normal View History

2019-12-24 11:29:14 +00:00
package main
import (
"testing"
)
func TestGetContentType(t *testing.T) {
for key, value := range map[string]ContentType{
"": UnsupportedType,
"test": UnsupportedType,
"application/x-www-form-urlencoded": WwwForm,
"application/json": Json,
"multipart/form-data": Multipart,
} {
t.Run(key, func(t *testing.T) {
got, err := GetContentType(key)
if got != value {
t.Errorf("Wrong ContentType")
}
if value == UnsupportedType && err == nil {
t.Errorf("Error is nil")
}
})
}
}