mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Support filtering by StashID endpoint (#3005)
* Add endpoint to stash_id filter in UI Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -2091,6 +2091,104 @@ func sceneQueryQ(ctx context.Context, t *testing.T, sqb models.SceneReader, q st
|
||||
assert.Len(t, scenes, totalScenes)
|
||||
}
|
||||
|
||||
func TestSceneQuery(t *testing.T) {
|
||||
var (
|
||||
endpoint = sceneStashID(sceneIdxWithGallery).Endpoint
|
||||
stashID = sceneStashID(sceneIdxWithGallery).StashID
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
findFilter *models.FindFilterType
|
||||
filter *models.SceneFilterType
|
||||
includeIdxs []int
|
||||
excludeIdxs []int
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
"stash id with endpoint",
|
||||
nil,
|
||||
&models.SceneFilterType{
|
||||
StashIDEndpoint: &models.StashIDCriterionInput{
|
||||
Endpoint: &endpoint,
|
||||
StashID: &stashID,
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
},
|
||||
[]int{sceneIdxWithGallery},
|
||||
nil,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"exclude stash id with endpoint",
|
||||
nil,
|
||||
&models.SceneFilterType{
|
||||
StashIDEndpoint: &models.StashIDCriterionInput{
|
||||
Endpoint: &endpoint,
|
||||
StashID: &stashID,
|
||||
Modifier: models.CriterionModifierNotEquals,
|
||||
},
|
||||
},
|
||||
nil,
|
||||
[]int{sceneIdxWithGallery},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"null stash id with endpoint",
|
||||
nil,
|
||||
&models.SceneFilterType{
|
||||
StashIDEndpoint: &models.StashIDCriterionInput{
|
||||
Endpoint: &endpoint,
|
||||
Modifier: models.CriterionModifierIsNull,
|
||||
},
|
||||
},
|
||||
nil,
|
||||
[]int{sceneIdxWithGallery},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"not null stash id with endpoint",
|
||||
nil,
|
||||
&models.SceneFilterType{
|
||||
StashIDEndpoint: &models.StashIDCriterionInput{
|
||||
Endpoint: &endpoint,
|
||||
Modifier: models.CriterionModifierNotNull,
|
||||
},
|
||||
},
|
||||
[]int{sceneIdxWithGallery},
|
||||
nil,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
runWithRollbackTxn(t, tt.name, func(t *testing.T, ctx context.Context) {
|
||||
assert := assert.New(t)
|
||||
|
||||
results, err := db.Scene.Query(ctx, models.SceneQueryOptions{
|
||||
SceneFilter: tt.filter,
|
||||
QueryOptions: models.QueryOptions{
|
||||
FindFilter: tt.findFilter,
|
||||
},
|
||||
})
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("PerformerStore.Query() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
|
||||
include := indexesToIDs(performerIDs, tt.includeIdxs)
|
||||
exclude := indexesToIDs(performerIDs, tt.excludeIdxs)
|
||||
|
||||
for _, i := range include {
|
||||
assert.Contains(results.IDs, i)
|
||||
}
|
||||
for _, e := range exclude {
|
||||
assert.NotContains(results.IDs, e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSceneQueryPath(t *testing.T) {
|
||||
const (
|
||||
sceneIdx = 1
|
||||
|
||||
Reference in New Issue
Block a user