stash/pkg/sqlite/scene_marker_test.go
WithoutPants 1e04deb3d4
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
2021-01-18 12:23:20 +11:00

75 lines
1.4 KiB
Go

// +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