Bump version and create a couple of unit tests

pull/3/head
Toni Melisma 4 years ago
parent 4c72f94ef5
commit 600d53e1ad
No known key found for this signature in database
GPG Key ID: FFF9A7EDDEA34756

@ -204,7 +204,7 @@ func isVideoFile(filename string) bool {
func isImageFile(filename string) bool {
switch filepath.Ext(strings.ToLower(filename)) {
case ".jpg", ".jpeg", ".heic", ".png", ".gif", ".tif":
case ".jpg", ".jpeg", ".heic", ".png", ".gif", ".tif", ".tiff":
return true
case ".cr2", ".raw", ".arw":
return true

@ -2,8 +2,43 @@ package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHello(t *testing.T) {
t.Logf("placeholder")
func TestIsVideoFile(t *testing.T) {
assert.Equal(t, isVideoFile("test.txt"), false, "false positive")
assert.Equal(t, isVideoFile(""), false, "false positive")
assert.Equal(t, isVideoFile("test.mp4"), true, "false negative")
assert.Equal(t, isVideoFile("test.mov"), true, "false negative")
assert.Equal(t, isVideoFile("test.3gp"), true, "false negative")
assert.Equal(t, isVideoFile("test.avi"), true, "false negative")
assert.Equal(t, isVideoFile("test.mts"), true, "false negative")
assert.Equal(t, isVideoFile("test.m4v"), true, "false negative")
assert.Equal(t, isVideoFile("test.mpg"), true, "false negative")
assert.Equal(t, isVideoFile("test.MP4"), true, "false negative")
}
func TestIsImageFile(t *testing.T) {
assert.Equal(t, isImageFile("test.txt"), false, "false positive")
assert.Equal(t, isImageFile(""), false, "false positive")
assert.Equal(t, isImageFile("test.jpg"), true, "false negative")
assert.Equal(t, isImageFile("test.JPG"), true, "false negative")
assert.Equal(t, isImageFile("test.jpeg"), true, "false negative")
assert.Equal(t, isImageFile("test.heic"), true, "false negative")
assert.Equal(t, isImageFile("test.png"), true, "false negative")
assert.Equal(t, isImageFile("test.tif"), true, "false negative")
assert.Equal(t, isImageFile("test.tiff"), true, "false negative")
}
func TestIsMediaFile(t *testing.T) {
assert.Equal(t, isMediaFile("test.txt"), false, "false positive")
assert.Equal(t, isMediaFile("test.jpg"), true, "false negative")
assert.Equal(t, isMediaFile("test.mp4"), true, "false negative")
}
func TestStripExtension(t *testing.T) {
assert.Equal(t, stripExtension("../tmp/filename.txt"), "../tmp/filename", "mismatch")
assert.Equal(t, stripExtension("/tmp/filename.txt"), "/tmp/filename", "mismatch")
assert.Equal(t, stripExtension("filename.txt"), "filename", "mismatch")
}

@ -4,8 +4,10 @@ go 1.15
require (
github.com/cheggaaa/pb/v3 v3.0.5
github.com/davidbyttow/govips/v2 v2.0.3-0.20201110212606-9418e4e2de8b
github.com/davidbyttow/govips/v2 v2.1.0
github.com/fatih/color v1.10.0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)

@ -7,6 +7,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidbyttow/govips/v2 v2.0.3-0.20201110212606-9418e4e2de8b h1:3G5u3xPPMJ/IN4dgnWG6GH68mDOmVlKRqxy5m/YdkLg=
github.com/davidbyttow/govips/v2 v2.0.3-0.20201110212606-9418e4e2de8b/go.mod h1:goq38QD8XEMz2aWEeucEZqRxAWsemIN40vbUqfPfTAw=
github.com/davidbyttow/govips/v2 v2.1.0 h1:n18SBq7dnjvW1+WKk65tnuF9IBaA4A1YHYrQ1iKZ28g=
github.com/davidbyttow/govips/v2 v2.1.0/go.mod h1:goq38QD8XEMz2aWEeucEZqRxAWsemIN40vbUqfPfTAw=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
@ -58,3 +60,5 @@ gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLF
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

Loading…
Cancel
Save