mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Support for assigning any image from a gallery as the cover (#5053)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -2973,6 +2973,34 @@ func TestGalleryQueryHasChapters(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGallerySetAndResetCover(t *testing.T) {
|
||||
withTxn(func(ctx context.Context) error {
|
||||
sqb := db.Gallery
|
||||
|
||||
imagePath2 := getFilePath(folderIdxWithImageFiles, getImageBasename(imageIdx2WithGallery))
|
||||
|
||||
result, err := db.Image.CoverByGalleryID(ctx, galleryIDs[galleryIdxWithTwoImages])
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, result)
|
||||
|
||||
err = sqb.SetCover(ctx, galleryIDs[galleryIdxWithTwoImages], imageIDs[imageIdx2WithGallery])
|
||||
assert.Nil(t, err)
|
||||
|
||||
result, err = db.Image.CoverByGalleryID(ctx, galleryIDs[galleryIdxWithTwoImages])
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, result.Path, imagePath2)
|
||||
|
||||
err = sqb.ResetCover(ctx, galleryIDs[galleryIdxWithTwoImages])
|
||||
assert.Nil(t, err)
|
||||
|
||||
result, err = db.Image.CoverByGalleryID(ctx, galleryIDs[galleryIdxWithTwoImages])
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, result)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// TODO Count
|
||||
// TODO All
|
||||
// TODO Query
|
||||
|
||||
Reference in New Issue
Block a user