✅ Added methods tests for MediaType domain
This commit is contained in:
parent
6679806534
commit
9a18b8c56f
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue