38 lines
839 B
Go
38 lines
839 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|