perf(image): 图片列表默认加载缩略图
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestObjectReadKeysFallsBackToOriginalImage(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
key string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
name: "original key",
|
||||
key: "listing/account.webp",
|
||||
want: []string{"listing/account.webp"},
|
||||
},
|
||||
{
|
||||
name: "thumbnail fallback",
|
||||
key: "listing/account.webp.thumb.jpg",
|
||||
want: []string{"listing/account.webp.thumb.jpg", "listing/account.webp"},
|
||||
},
|
||||
{
|
||||
name: "medium fallback",
|
||||
key: "listing/account.webp.medium.jpg",
|
||||
want: []string{"listing/account.webp.medium.jpg", "listing/account.webp"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := objectReadKeys(tt.key); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Fatalf("objectReadKeys(%q) = %#v, want %#v", tt.key, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user