aboutsummaryrefslogtreecommitdiff
path: root/mediaapi/storage
diff options
context:
space:
mode:
authorBrian Meek <brian@hntlabs.com>2022-04-29 09:32:58 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-04-29 09:32:58 +0100
commitd28d0ee66e22402bebd791a46de33c8bf3169e26 (patch)
treee8dee8c2881029055460ef4334dc267fc76ad96e /mediaapi/storage
parent2a4517f8e6c7f68d8bd94f0b4640b142f2d3ac52 (diff)
Fix `TestThumbnailsStorage` failing when media results come back in non-deterministic order; silence expected
error when tests are run multiple times against the same postgres database (cherry-picked from #2395) Signed-off-by: Brian Meek <brian@hntlabs.com>
Diffstat (limited to 'mediaapi/storage')
-rw-r--r--mediaapi/storage/storage_test.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/mediaapi/storage/storage_test.go b/mediaapi/storage/storage_test.go
index 8d340304..fa88cd8e 100644
--- a/mediaapi/storage/storage_test.go
+++ b/mediaapi/storage/storage_test.go
@@ -123,11 +123,19 @@ func TestThumbnailsStorage(t *testing.T) {
t.Fatalf("expected %d stored thumbnail metadata, got %d", len(thumbnails), len(gotMediadatas))
}
for i := range gotMediadatas {
- if !reflect.DeepEqual(thumbnails[i].MediaMetadata, gotMediadatas[i].MediaMetadata) {
- t.Fatalf("expected metadata %+v, got %v", thumbnails[i].MediaMetadata, gotMediadatas[i].MediaMetadata)
+ // metadata may be returned in a different order than it was stored, perform a search
+ metaDataMatches := func() bool {
+ for _, t := range thumbnails {
+ if reflect.DeepEqual(t.MediaMetadata, gotMediadatas[i].MediaMetadata) && reflect.DeepEqual(t.ThumbnailSize, gotMediadatas[i].ThumbnailSize) {
+ return true
+ }
+ }
+ return false
}
- if !reflect.DeepEqual(thumbnails[i].ThumbnailSize, gotMediadatas[i].ThumbnailSize) {
- t.Fatalf("expected metadata %+v, got %v", thumbnails[i].ThumbnailSize, gotMediadatas[i].ThumbnailSize)
+
+ if !metaDataMatches() {
+ t.Fatalf("expected metadata %+v, got %+v", thumbnails[i].MediaMetadata, gotMediadatas[i].MediaMetadata)
+
}
}
})