-
Notifications
You must be signed in to change notification settings - Fork 3
/
filters_test.go
76 lines (69 loc) · 2.02 KB
/
filters_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package rawg
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestNewGamesFilter(t *testing.T) {
from1, _ := time.Parse("2006-01-02", "2010-01-01")
to1, _ := time.Parse("2006-01-02", "2018-12-31")
dateRangeFirst := DateRange{
From: from1,
To: to1,
}
from2, _ := time.Parse("2006-01-02", "1960-01-01")
to2, _ := time.Parse("2006-01-02", "1969-12-31")
dateRangeSecond := DateRange{
From: from2,
To: to2,
}
updated1, _ := time.Parse("2006-01-02", "2020-01-01")
updated2, _ := time.Parse("2006-01-02", "2020-10-15")
filter := NewGamesFilter().
SetPage(1).
SetPageSize(2).
SetSearch("gta5").
SetParentPlatforms(1, 2).
SetPlatforms(3, 4).
SetStores(5, 6).
SetDevelopers(7, "feral-interactive").
SetPublishers(8, "electronic-arts").
SetGenres(9, "action", "indie").
SetTags("singleplayer", 31).
SetCreators(28, "mike-morasky").
SetDates(dateRangeFirst, dateRangeSecond).
SetUpdated(updated1, updated2).
SetPlatformsCount(10).
ExcludeCollection(123).
WithoutAdditions().
WithoutParents().
WithoutGameSeries().
SetOrdering("-name").
SetMetacritic(20, 80).
WithSearchExact().
WithSearchPrecise()
assert.Equal(t, map[string]interface{}{
"creators": "28,mike-morasky",
"dates": "2010-01-01,2018-12-31.1960-01-01,1969-12-31",
"developers": "7,feral-interactive",
"exclude_additions": true,
"exclude_collection": 123,
"exclude_game_series": true,
"exclude_parents": true,
"search_exact": true,
"search_precise": true,
"genres": "9,action,indie",
"ordering": "-name",
"page": 1,
"page_size": 2,
"parent_platforms": "1,2",
"platforms": "3,4",
"platforms_count": 10,
"publishers": "8,electronic-arts",
"search": "gta5",
"stores": "5,6",
"tags": "singleplayer,31",
"metacritic": "20,80",
"updated": "2020-01-01,2020-10-15",
}, filter.GetParams())
}