-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_test.go
41 lines (35 loc) · 1.08 KB
/
query_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package kickass
import "testing"
var mockQuery = &Query{
Search: "star wars",
User: "YIFY",
OrderBy: "seeders",
Order: "desc",
Category: "movies",
ImdbID: "tt2488496",
Pages: 2,
}
func TestQueryURLParams(t *testing.T) {
// Test with mock query
expectedURLParams := "?field=seeders&page=2&sorder=desc"
if mockQuery.urlParams(2) != expectedURLParams {
t.Errorf("invalid URL params, expected %q, got %q", expectedURLParams, mockQuery.urlParams(2))
}
// Test with empty query
q := &Query{}
if q.urlParams(0) != "" {
t.Errorf("invalid URL params, expected nothing, got %q", q.urlParams(0))
}
}
func TestQuerySearchField(t *testing.T) {
// Test with mock query
expectedSearch := "star wars user:YIFY category:movies imdb:2488496"
if mockQuery.searchField() != expectedSearch {
t.Errorf("invalid search field, expected %q, got %q", expectedSearch, mockQuery.searchField())
}
// Test with simple search
q := &Query{Search: mockQuery.Search}
if q.searchField() != q.Search {
t.Errorf("invalid search field, expected %q, got %q", mockQuery.Search, q.searchField())
}
}