You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
760 B
45 lines
760 B
package mime_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"gitoa.ru/go-4devs/mime"
|
|
)
|
|
|
|
func TestMimeMarshalText(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
res, err := mime.ApplicationJavascript.MarshalText()
|
|
require.Equal(t, "application/javascript", string(res))
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestMimeUnmarshalText(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cases := []struct {
|
|
data string
|
|
expext mime.Mime
|
|
}{
|
|
{
|
|
data: "text/html",
|
|
expext: mime.TextHTML,
|
|
},
|
|
{
|
|
data: "text/HTML",
|
|
expext: mime.TextHTML,
|
|
},
|
|
{
|
|
data: "any text",
|
|
expext: mime.Unrecognized,
|
|
},
|
|
}
|
|
|
|
for _, cs := range cases {
|
|
var in mime.Mime
|
|
err := in.UnmarshalText([]byte(cs.data))
|
|
require.Equal(t, cs.expext, in)
|
|
require.NoError(t, err)
|
|
}
|
|
}
|
|
|