Skip to content

Commit 09e8860

Browse files
committed
Fix search tests
1 parent 4fe71cf commit 09e8860

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pkg/discourse/search.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,9 @@ func generateSearchQueryString(query *SearchQuery) string {
223223
searchString = searchString[:len(searchString)-1]
224224
}
225225

226+
if searchString == "q" {
227+
searchString = ""
228+
}
229+
226230
return searchString
227231
}

pkg/discourse/search_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestGenerateSearchQueryString(t *testing.T) {
6060
MinViews: 0,
6161
MaxViews: -1,
6262
},
63-
"before:2024-04-27 after:2023-10-14",
63+
"q=before:2024-04-27 after:2023-10-14",
6464
},
6565
{
6666
"Tags In With and Status",
@@ -95,7 +95,7 @@ func TestGenerateSearchQueryString(t *testing.T) {
9595
MinViews: 0,
9696
MaxViews: -1,
9797
},
98-
"tags:api,docs,test in:bookmarks in:first with:images status:closed,open",
98+
"q=tags:api,docs,test in:bookmarks in:first with:images status:closed,open",
9999
},
100100
{
101101
"All tags required",
@@ -130,7 +130,7 @@ func TestGenerateSearchQueryString(t *testing.T) {
130130
MinViews: 0,
131131
MaxViews: -1,
132132
},
133-
"tags:api+docs+test in:bookmarks in:first with:images status:closed,open",
133+
"q=tags:api+docs+test in:bookmarks in:first with:images status:closed,open",
134134
},
135135
{
136136
"Other Fields",
@@ -153,7 +153,7 @@ func TestGenerateSearchQueryString(t *testing.T) {
153153
MinViews: 4,
154154
MaxViews: -1,
155155
},
156-
"@lvoytek #server order:latest_topic assigned:lvoytek group:canonical group_messages:canonical min_posts:3 min_views:4",
156+
"q=@lvoytek #server order:latest_topic assigned:lvoytek group:canonical group_messages:canonical min_posts:3 min_views:4",
157157
},
158158
{
159159
"Custom Fields",
@@ -164,14 +164,14 @@ func TestGenerateSearchQueryString(t *testing.T) {
164164
"useless": {},
165165
},
166166
},
167-
"@lvoytek meta:first,second",
167+
"q=@lvoytek meta:first,second",
168168
},
169169
{
170170
"Search term only",
171171
SearchQuery{
172172
Term: "hello world",
173173
},
174-
"hello world",
174+
"q=hello world",
175175
},
176176
{
177177
"Search with user and category",
@@ -180,7 +180,7 @@ func TestGenerateSearchQueryString(t *testing.T) {
180180
Username: "system",
181181
Category: "announcements",
182182
},
183-
"hello world @system #announcements",
183+
"q=hello world @system #announcements",
184184
},
185185
}
186186

0 commit comments

Comments
 (0)