aboutsummaryrefslogtreecommitdiff
path: root/internal/api/query_test.go
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-08-26 16:59:34 +0530
committerGitHub <noreply@github.com>2026-08-26 16:59:34 +0530
commit7c346191ca616d5aef20147c46fd45ee856477aa (patch)
tree0535b1eae4cf0fa21d24e2ed3e7ab4875c0e70f6 /internal/api/query_test.go
parent9b541ca2d0a639eebd9610fcd6385e841da68e0a (diff)
parentbd8fab9ace7444d1b97a6df7b2d81ef981808a05 (diff)
downloadgalleryd-7c346191ca616d5aef20147c46fd45ee856477aa.tar.xz
galleryd-7c346191ca616d5aef20147c46fd45ee856477aa.zip
Merge pull request #14 from RanXom/feat/api
Feat/api: add photo search by relative path
Diffstat (limited to 'internal/api/query_test.go')
-rw-r--r--internal/api/query_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/api/query_test.go b/internal/api/query_test.go
index cbfe89a..a1effe7 100644
--- a/internal/api/query_test.go
+++ b/internal/api/query_test.go
@@ -1,6 +1,7 @@
package api
import (
+ "net/http"
"net/http/httptest"
"testing"
@@ -209,3 +210,41 @@ func TestParseQueryOrderWithoutSort(t *testing.T) {
)
}
}
+
+func TestParseQueryExtension(t *testing.T) {
+ req := httptest.NewRequest(
+ http.MethodGet,
+ "/api/photos?extension=jpg",
+ nil,
+ )
+
+ got, err := parseQuery(req)
+ if err != nil {
+ t.Fatalf("parseQuery() error = %v", err)
+ }
+
+ if got.Extension != "jpg" {
+ t.Fatalf("expected extension %q, got %q", "jpg", got.Extension)
+ }
+}
+
+func TestParseQuerySearch(t *testing.T) {
+ req := httptest.NewRequest(
+ "http.MethodGet",
+ "/api/photos?q=vacation",
+ nil,
+ )
+
+ got, err := parseQuery(req)
+ if err != nil {
+ t.Fatalf("parseQuery() error = %v", err)
+ }
+
+ if got.Search != "vacation" {
+ t.Fatalf(
+ "expected search %q, got %q",
+ "vacation",
+ got.Search,
+ )
+ }
+}