mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-27 00:00:49 -05:00
99 lines
1.9 KiB
Go
99 lines
1.9 KiB
Go
package thumbnail_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kovidgoyal/imaging"
|
|
tAssert "github.com/stretchr/testify/assert"
|
|
|
|
"github.com/opencloud-eu/opencloud/services/thumbnails/pkg/thumbnail"
|
|
)
|
|
|
|
func TestProcessorFor(t *testing.T) {
|
|
tests := []struct {
|
|
id string
|
|
fileType string
|
|
wantP thumbnail.Processor
|
|
wantE error
|
|
}{
|
|
{
|
|
id: "fit",
|
|
fileType: "",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "fit", Converter: imaging.Fit},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "fit",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "fit"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "FIT",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "fit"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "resize",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "resize"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "RESIZE",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "resize"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "fill",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "fill"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "FILL",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "fill"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "thumbnail",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "thumbnail"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "THUMBNAIL",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{Slug: "thumbnail"},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "",
|
|
fileType: "jpg",
|
|
wantP: thumbnail.DefinableProcessor{},
|
|
wantE: nil,
|
|
},
|
|
{
|
|
id: "",
|
|
fileType: "gif",
|
|
wantP: thumbnail.DefinableProcessor{},
|
|
wantE: nil,
|
|
},
|
|
}
|
|
|
|
assert := tAssert.New(t)
|
|
|
|
for _, tt := range tests {
|
|
tt := tt
|
|
t.Run("", func(t *testing.T) {
|
|
p, e := thumbnail.ProcessorFor(tt.id, tt.fileType)
|
|
assert.Equal(p.ID(), tt.wantP.ID())
|
|
assert.Equal(e, tt.wantE)
|
|
})
|
|
}
|
|
|
|
}
|