(Feat): Initial Commit
This commit is contained in:
30
internal/util/mime/mime_test.go
Normal file
30
internal/util/mime/mime_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package mime_test
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"allaboutapps.dev/aw/go-starter/internal/util"
|
||||
"allaboutapps.dev/aw/go-starter/internal/util/mime"
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestKnownMIME(t *testing.T) {
|
||||
filePath := filepath.Join(util.GetProjectRootDir(), "test", "testdata", "example.jpg")
|
||||
|
||||
var detectedMIME mime.MIME
|
||||
var err error
|
||||
detectedMIME, err = mimetype.DetectFile(filePath)
|
||||
require.NoError(t, err)
|
||||
|
||||
var knownMIME mime.MIME = &mime.KnownMIME{
|
||||
MimeType: "image/jpeg",
|
||||
FileExtension: ".jpg",
|
||||
}
|
||||
|
||||
assert.Equal(t, detectedMIME.Extension(), knownMIME.Extension())
|
||||
assert.Equal(t, detectedMIME.String(), knownMIME.String())
|
||||
assert.True(t, knownMIME.Is(detectedMIME.String()))
|
||||
}
|
||||
Reference in New Issue
Block a user