Add tests for invalid thumbnail type and invalid image format for thumbnail function

This commit is contained in:
Theresa Gresch 2019-07-09 12:46:43 +02:00
parent b99753b051
commit 46f997e8ba

View file

@ -22,6 +22,7 @@ func TestMediaFile_Thumbnail(t *testing.T) {
defer os.RemoveAll(thumbsPath)
t.Run("/elephants.jpg", func(t *testing.T) {
image, err := NewMediaFile(conf.ExamplesPath() + "/elephants.jpg")
assert.Nil(t, err)
@ -30,6 +31,25 @@ func TestMediaFile_Thumbnail(t *testing.T) {
assert.Empty(t, err)
assert.FileExists(t, thumbnail)
})
t.Run("invalid image format", func(t *testing.T) {
image, err := NewMediaFile(conf.ExamplesPath() + "/canon_eos_6d.xmp")
assert.Nil(t, err)
thumbnail, err := image.Thumbnail(thumbsPath, "tile_500")
assert.Equal(t, "could not create thumbnail: image: unknown format", err.Error())
t.Log(thumbnail)
})
t.Run("invalid thumbnail type", func(t *testing.T) {
image, err := NewMediaFile(conf.ExamplesPath() + "/elephants.jpg")
assert.Nil(t, err)
thumbnail, err := image.Thumbnail(thumbsPath, "invalid_500")
assert.Equal(t, "invalid type: invalid_500", err.Error())
t.Log(thumbnail)
})
}
func TestCreateThumbnailsFromOriginals(t *testing.T) {