forked from stashapp/stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Querybuilder integration tests (stashapp#513)
* Vet fixes * Change low resolution to < 480
- Loading branch information
1 parent
2234949
commit d2b0644
Showing
33 changed files
with
8,490 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// +build integration | ||
|
||
package models_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/stashapp/stash/pkg/models" | ||
) | ||
|
||
func TestGalleryFind(t *testing.T) { | ||
gqb := models.NewGalleryQueryBuilder() | ||
|
||
const galleryIdx = 0 | ||
gallery, err := gqb.Find(galleryIDs[galleryIdx]) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, getGalleryStringValue(galleryIdx, "Path"), gallery.Path) | ||
|
||
gallery, err = gqb.Find(0) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Nil(t, gallery) | ||
} | ||
|
||
func TestGalleryFindByChecksum(t *testing.T) { | ||
gqb := models.NewGalleryQueryBuilder() | ||
|
||
const galleryIdx = 0 | ||
galleryChecksum := getGalleryStringValue(galleryIdx, "Checksum") | ||
gallery, err := gqb.FindByChecksum(galleryChecksum, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, getGalleryStringValue(galleryIdx, "Path"), gallery.Path) | ||
|
||
galleryChecksum = "not exist" | ||
gallery, err = gqb.FindByChecksum(galleryChecksum, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Nil(t, gallery) | ||
} | ||
|
||
func TestGalleryFindByPath(t *testing.T) { | ||
gqb := models.NewGalleryQueryBuilder() | ||
|
||
const galleryIdx = 0 | ||
galleryPath := getGalleryStringValue(galleryIdx, "Path") | ||
gallery, err := gqb.FindByPath(galleryPath) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, galleryPath, gallery.Path) | ||
|
||
galleryPath = "not exist" | ||
gallery, err = gqb.FindByPath(galleryPath) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Nil(t, gallery) | ||
} | ||
|
||
func TestGalleryFindBySceneID(t *testing.T) { | ||
gqb := models.NewGalleryQueryBuilder() | ||
|
||
sceneID := sceneIDs[sceneIdxWithGallery] | ||
gallery, err := gqb.FindBySceneID(sceneID, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, getGalleryStringValue(galleryIdxWithScene, "Path"), gallery.Path) | ||
|
||
gallery, err = gqb.FindBySceneID(0, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding gallery: %s", err.Error()) | ||
} | ||
|
||
assert.Nil(t, gallery) | ||
} | ||
|
||
// TODO ValidGalleriesForScenePath | ||
// TODO Count | ||
// TODO All | ||
// TODO Query | ||
// TODO Update | ||
// TODO Destroy | ||
// TODO ClearGalleryId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// +build integration | ||
|
||
package models_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/stashapp/stash/pkg/models" | ||
) | ||
|
||
func TestMovieFindBySceneID(t *testing.T) { | ||
mqb := models.NewMovieQueryBuilder() | ||
sceneID := sceneIDs[sceneIdxWithMovie] | ||
|
||
movies, err := mqb.FindBySceneID(sceneID, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding movie: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, 1, len(movies), "expect 1 movie") | ||
|
||
movie := movies[0] | ||
assert.Equal(t, getMovieStringValue(movieIdxWithScene, "Name"), movie.Name.String) | ||
|
||
movies, err = mqb.FindBySceneID(0, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding movie: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, 0, len(movies)) | ||
} | ||
|
||
// TODO Update | ||
// TODO Destroy | ||
// TODO Find | ||
// TODO FindByName | ||
// TODO FindByNames | ||
// TODO Count | ||
// TODO All | ||
// TODO Query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// +build integration | ||
|
||
package models_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/stashapp/stash/pkg/models" | ||
) | ||
|
||
func TestPerformerFindBySceneID(t *testing.T) { | ||
pqb := models.NewPerformerQueryBuilder() | ||
sceneID := sceneIDs[sceneIdxWithPerformer] | ||
|
||
performers, err := pqb.FindBySceneID(sceneID, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding performer: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, 1, len(performers)) | ||
performer := performers[0] | ||
|
||
assert.Equal(t, getPerformerStringValue(performerIdxWithScene, "Name"), performer.Name.String) | ||
|
||
performers, err = pqb.FindBySceneID(0, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding performer: %s", err.Error()) | ||
} | ||
|
||
assert.Equal(t, 0, len(performers)) | ||
} | ||
|
||
// TODO Update | ||
// TODO Destroy | ||
// TODO Find | ||
// TODO FindNameBySceneID | ||
// TODO FindByNames | ||
// TODO Count | ||
// TODO All | ||
// TODO AllSlim | ||
// TODO Query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// +build integration | ||
|
||
package models_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/stashapp/stash/pkg/models" | ||
) | ||
|
||
func TestMarkerFindBySceneID(t *testing.T) { | ||
mqb := models.NewSceneMarkerQueryBuilder() | ||
|
||
sceneID := sceneIDs[sceneIdxWithMarker] | ||
markers, err := mqb.FindBySceneID(sceneID, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding markers: %s", err.Error()) | ||
} | ||
|
||
assert.Len(t, markers, 1) | ||
assert.Equal(t, markerIDs[markerIdxWithScene], markers[0].ID) | ||
|
||
markers, err = mqb.FindBySceneID(0, nil) | ||
|
||
if err != nil { | ||
t.Fatalf("Error finding marker: %s", err.Error()) | ||
} | ||
|
||
assert.Len(t, markers, 0) | ||
} | ||
|
||
// TODO Update | ||
// TODO Destroy | ||
// TODO Find | ||
// TODO CountByTagID | ||
// TODO GetMarkerStrings | ||
// TODO Wall | ||
// TODO Query |
Oops, something went wrong.