mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Data layer restructuring (#997)
* Move query builders to sqlite package * Add transaction system * Wrap model resolvers in transaction * Add error return value for StringSliceToIntSlice * Update/refactor mutation resolvers * Convert query builders * Remove unused join types * Add stash id unit tests * Use WAL journal mode
This commit is contained in:
75
pkg/sqlite/scene_marker_test.go
Normal file
75
pkg/sqlite/scene_marker_test.go
Normal file
@@ -0,0 +1,75 @@
|
||||
// +build integration
|
||||
|
||||
package sqlite_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMarkerFindBySceneID(t *testing.T) {
|
||||
withTxn(func(r models.Repository) error {
|
||||
mqb := r.SceneMarker()
|
||||
|
||||
sceneID := sceneIDs[sceneIdxWithMarker]
|
||||
markers, err := mqb.FindBySceneID(sceneID)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error finding markers: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Len(t, markers, 1)
|
||||
assert.Equal(t, markerIDs[markerIdxWithScene], markers[0].ID)
|
||||
|
||||
markers, err = mqb.FindBySceneID(0)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error finding marker: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Len(t, markers, 0)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestMarkerCountByTagID(t *testing.T) {
|
||||
withTxn(func(r models.Repository) error {
|
||||
mqb := r.SceneMarker()
|
||||
|
||||
markerCount, err := mqb.CountByTagID(tagIDs[tagIdxWithPrimaryMarker])
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("error calling CountByTagID: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Equal(t, 1, markerCount)
|
||||
|
||||
markerCount, err = mqb.CountByTagID(tagIDs[tagIdxWithMarker])
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("error calling CountByTagID: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Equal(t, 1, markerCount)
|
||||
|
||||
markerCount, err = mqb.CountByTagID(0)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("error calling CountByTagID: %s", err.Error())
|
||||
}
|
||||
|
||||
assert.Equal(t, 0, markerCount)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// TODO Update
|
||||
// TODO Destroy
|
||||
// TODO Find
|
||||
// TODO GetMarkerStrings
|
||||
// TODO Wall
|
||||
// TODO Query
|
||||
Reference in New Issue
Block a user