Skip to content

Commit

Permalink
Use Is method in tests instead of string comparƣson
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-vasile committed Mar 17, 2020
1 parent c64c025 commit 658159b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mimetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,20 @@ func TestDetect(t *testing.T) {
t.Fatal(err)
}

if mime := mimetype.Detect(data); mime.String() != expected {
if mime := mimetype.Detect(data); !mime.Is(expected) {
t.Errorf(errStr, fName, expected, mime.String(), nil)
}

if _, err := f.Seek(0, io.SeekStart); err != nil {
t.Fatal(err)
}

if mime, err := mimetype.DetectReader(f); mime.String() != expected {
if mime, err := mimetype.DetectReader(f); !mime.Is(expected) {
t.Errorf(errStr, fName, expected, mime.String(), err)
}
f.Close()

if mime, err := mimetype.DetectFile(fileName); mime.String() != expected {
if mime, err := mimetype.DetectFile(fileName); !mime.Is(expected) {
t.Errorf(errStr, fName, expected, mime.String(), err)
} else if mime.Extension() != filepath.Ext(fName) {
t.Errorf(extStr, fName, filepath.Ext(fName), mime.Extension())
Expand All @@ -214,7 +214,7 @@ func TestDetectReader(t *testing.T) {
r: f,
breakSize: 3,
}
if mime, err := mimetype.DetectReader(&r); mime.String() != expected {
if mime, err := mimetype.DetectReader(&r); !mime.Is(expected) {
t.Errorf(errStr, fName, expected, mime.String(), err)
}
f.Close()
Expand Down

0 comments on commit 658159b

Please sign in to comment.