aboutsummaryrefslogtreecommitdiff
path: root/internal/gallery/query_photos_test.go
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-22 18:20:15 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-22 18:20:15 +0530
commit8fb30a66a81a1f7150ebe86ed091e7c1651233a1 (patch)
treef23eb6ebdb05a0bfe6e998df5803dd687c8eaa85 /internal/gallery/query_photos_test.go
parenta9150facac14799f4d188062c01b6ed353d82588 (diff)
downloadgalleryd-8fb30a66a81a1f7150ebe86ed091e7c1651233a1.tar.xz
galleryd-8fb30a66a81a1f7150ebe86ed091e7c1651233a1.zip
feat(gallery): filter photos by extension
Diffstat (limited to 'internal/gallery/query_photos_test.go')
-rw-r--r--internal/gallery/query_photos_test.go57
1 files changed, 54 insertions, 3 deletions
diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go
index 05dab67..b72b6ec 100644
--- a/internal/gallery/query_photos_test.go
+++ b/internal/gallery/query_photos_test.go
@@ -251,12 +251,63 @@ func TestQueryPhotosSortByDateDescending(t *testing.T) {
assertIDs(t, got, "new", "mid", "old")
}
-func TestQueryPhotosIgnoresExtensionFilteringForNow(t *testing.T) {
- photos := makePhotos(3)
+func TestQueryPhotosFilterByExtension(t *testing.T) {
+ photos := []Photo{
+ {
+ ID: "jpg",
+ File: scanner.File{
+ RelativePath: "photo.jpg",
+ },
+ },
+ {
+ ID: "png",
+ File: scanner.File{
+ RelativePath: "photo.png",
+ },
+ },
+ {
+ ID: "jpg2",
+ File: scanner.File{
+ RelativePath: "anotherphoto.jpg",
+ },
+ },
+ }
+
+ got := QueryPhotos(photos, Query{
+ Extension: "jpg",
+ })
+
+ assertIDs(t, got, "jpg", "jpg2")
+}
+
+func TestQueryPhotosFilterThenSortThenPaginate(t *testing.T) {
+ photos := []Photo{
+ {
+ ID: "1",
+ File: scanner.File{
+ RelativePath: "a.png",
+ },
+ },
+ {
+ ID: "2",
+ File: scanner.File{
+ RelativePath: "c.jpg",
+ },
+ },
+ {
+ ID: "3",
+ File: scanner.File{
+ RelativePath: "a.jpg",
+ },
+ },
+ }
got := QueryPhotos(photos, Query{
Extension: "jpg",
+ Sort: SortByPath,
+ Order: SortAsc,
+ Limit: 1,
})
- assertIDs(t, got, "0", "1", "2")
+ assertIDs(t, got, "3")
}