mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
small refactorings of test code and some methods
This commit is contained in:
@@ -60,9 +60,7 @@ func EncoderForType(fileType string) Encoder {
|
||||
switch strings.ToLower(fileType) {
|
||||
case "png":
|
||||
return PngEncoder{}
|
||||
case "jpg":
|
||||
fallthrough
|
||||
case "jpeg":
|
||||
case "jpg", "jpeg":
|
||||
return JpegEncoder{}
|
||||
default:
|
||||
return nil
|
||||
|
||||
22
thumbnails/pkg/thumbnail/encoding_test.go
Normal file
22
thumbnails/pkg/thumbnail/encoding_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package thumbnail
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEncoderForType(t *testing.T) {
|
||||
table := map[string]Encoder{
|
||||
"jpg": JpegEncoder{},
|
||||
"JPG": JpegEncoder{},
|
||||
"jpeg": JpegEncoder{},
|
||||
"JPEG": JpegEncoder{},
|
||||
"png": PngEncoder{},
|
||||
"PNG": PngEncoder{},
|
||||
"invalid": nil,
|
||||
}
|
||||
|
||||
for k, v := range table {
|
||||
e := EncoderForType(k)
|
||||
if e != v {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user