perf(image): 图片列表默认加载缩略图

This commit is contained in:
yml
2026-11-24 22:30:37 +08:00
parent 3cc61615f9
commit 43df96a973
22 changed files with 227 additions and 85 deletions
@@ -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)
}
})
}
}