mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add Chapters for Galleries (#3289)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
44
pkg/sqlite/gallery_chapter_test.go
Normal file
44
pkg/sqlite/gallery_chapter_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package sqlite_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stashapp/stash/pkg/sqlite"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestChapterFindByGalleryID(t *testing.T) {
|
||||
withTxn(func(ctx context.Context) error {
|
||||
mqb := sqlite.GalleryChapterReaderWriter
|
||||
|
||||
galleryID := galleryIDs[galleryIdxWithChapters]
|
||||
chapters, err := mqb.FindByGalleryID(ctx, galleryID)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error finding chapters: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Greater(t, len(chapters), 0)
|
||||
for _, chapter := range chapters {
|
||||
assert.Equal(t, galleryIDs[galleryIdxWithChapters], int(chapter.GalleryID.Int64))
|
||||
}
|
||||
|
||||
chapters, err = mqb.FindByGalleryID(ctx, 0)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error finding chapter: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Len(t, chapters, 0)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// TODO Update
|
||||
// TODO Destroy
|
||||
// TODO Find
|
||||
Reference in New Issue
Block a user