v0.4.0: scroll log, worker slots, disk skip, color gradient, parallel export
This commit is contained in:
@@ -85,12 +85,41 @@ func TestParseAssetsJSON(t *testing.T) {
|
||||
want: []Asset{{ID: "asset1", Filename: "IMG_0001.JPG"}},
|
||||
wantTotal: 1,
|
||||
},
|
||||
{
|
||||
name: "asset with metadata",
|
||||
json: `{"assets":[{"id":"a1","filename":"IMG.JPG","cloud":"local","mediaType":"image","pixelWidth":4032,"pixelHeight":3024,"duration":0,"isFavorite":true,"hasAdjustments":false,"resources":[{"type":"photo","filename":"IMG.JPG","uti":"public.heic","local":true}]}],"total":1}`,
|
||||
want: []Asset{{
|
||||
ID: "a1", Filename: "IMG.JPG", Cloud: "local",
|
||||
MediaType: "image", PixelWidth: 4032, PixelHeight: 3024,
|
||||
IsFavorite: true, HasAdjustments: false,
|
||||
Resources: []AssetResource{{Type: "photo", Filename: "IMG.JPG", UTI: "public.heic", Local: true}},
|
||||
}},
|
||||
wantTotal: 1,
|
||||
},
|
||||
{
|
||||
name: "video asset with duration",
|
||||
json: `{"assets":[{"id":"v1","filename":"clip.mov","cloud":"cloud","mediaType":"video","pixelWidth":1920,"pixelHeight":1080,"duration":12.5}],"total":1}`,
|
||||
want: []Asset{{
|
||||
ID: "v1", Filename: "clip.mov", Cloud: "cloud",
|
||||
MediaType: "video", PixelWidth: 1920, PixelHeight: 1080, Duration: 12.5,
|
||||
}},
|
||||
wantTotal: 1,
|
||||
},
|
||||
{
|
||||
name: "multiple assets",
|
||||
json: `{"assets":[{"id":"a1","filename":"a.jpg"},{"id":"a2","filename":"b.jpg"},{"id":"a3","filename":"c.jpg"}],"total":3}`,
|
||||
want: []Asset{{ID: "a1", Filename: "a.jpg"}, {ID: "a2", Filename: "b.jpg"}, {ID: "a3", Filename: "c.jpg"}},
|
||||
wantTotal: 3,
|
||||
},
|
||||
{
|
||||
name: "asset with creationDate",
|
||||
json: `{"assets":[{"id":"d1","filename":"photo.jpg","creationDate":"2024-06-15T12:30:00+0200"}],"total":1}`,
|
||||
want: func() []Asset {
|
||||
d := "2024-06-15T12:30:00+0200"
|
||||
return []Asset{{ID: "d1", Filename: "photo.jpg", CreationDate: &d}}
|
||||
}(),
|
||||
wantTotal: 1,
|
||||
},
|
||||
{
|
||||
name: "error response",
|
||||
json: `{"error":"album not found"}`,
|
||||
@@ -131,7 +160,7 @@ func TestParseAssetsJSON(t *testing.T) {
|
||||
return
|
||||
}
|
||||
for i := range got {
|
||||
if got[i] != tt.want[i] {
|
||||
if !equalAsset(got[i], tt.want[i]) {
|
||||
t.Errorf("ParseAssetsJSON()[%d] = %+v, want %+v", i, got[i], tt.want[i])
|
||||
}
|
||||
}
|
||||
@@ -438,3 +467,24 @@ func equalCollectionNode(a, b CollectionNode) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func equalAsset(a, b Asset) bool {
|
||||
if a.ID != b.ID || a.Filename != b.Filename || a.Cloud != b.Cloud || a.MediaType != b.MediaType || a.PixelWidth != b.PixelWidth || a.PixelHeight != b.PixelHeight || a.Duration != b.Duration || a.IsFavorite != b.IsFavorite || a.HasAdjustments != b.HasAdjustments {
|
||||
return false
|
||||
}
|
||||
if (a.CreationDate == nil) != (b.CreationDate == nil) {
|
||||
return false
|
||||
}
|
||||
if a.CreationDate != nil && b.CreationDate != nil && *a.CreationDate != *b.CreationDate {
|
||||
return false
|
||||
}
|
||||
if len(a.Resources) != len(b.Resources) {
|
||||
return false
|
||||
}
|
||||
for i := range a.Resources {
|
||||
if a.Resources[i] != b.Resources[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user