Added methods tests for MediaType domain

This commit is contained in:
Maxim Lebedev 2023-11-10 06:15:13 +06:00
parent 6679806534
commit 9a18b8c56f
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package domain_test
import (
"testing"
"source.toby3d.me/toby3d/home/internal/domain"
)
func TestMediaType_Type(t *testing.T) {
t.Parallel()
for name, tc := range map[string]struct {
input string
expect string
}{
"exists": {input: "image/jpeg", expect: "image/jpeg"},
"main": {input: "image/", expect: ""},
"sub": {input: "/jpeg", expect: ""},
"params": {input: "image/svg+xml", expect: "image/svg+xml"},
} {
tc, name := tc, name
t.Run(name, func(t *testing.T) {
t.Parallel()
actual := domain.NewMediaType(tc.input).Type()
if actual != tc.expect {
t.Errorf("got '%s', want '%s'", actual, tc.expect)
}
})
}
}