-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprice_params_test.go
144 lines (116 loc) · 6.42 KB
/
price_params_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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package atomicasset
import (
"net/url"
"testing"
"github.com/sonh/qs"
"github.com/stretchr/testify/assert"
)
func TestRequest_PriceSalesRequestParams(t *testing.T) {
tests := []struct {
name string
input PriceSalesRequestParams
expected url.Values
}{
{"Empty", PriceSalesRequestParams{}, url.Values{}},
{"Collection", PriceSalesRequestParams{Collection: "col"}, url.Values{"collection_name": []string{"col"}}},
{"Schema", PriceSalesRequestParams{Schema: "val"}, url.Values{"schema_name": []string{"val"}}},
{"TemplateID", PriceSalesRequestParams{TemplateID: 1234}, url.Values{"template_id": []string{"1234"}}},
{"Burned", PriceSalesRequestParams{Burned: true}, url.Values{"burned": []string{"true"}}},
{"Symbol", PriceSalesRequestParams{Symbol: "WAX"}, url.Values{"symbol": []string{"WAX"}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v, err := qs.NewEncoder().Values(tt.input)
assert.NoError(t, err)
assert.EqualValues(t, tt.expected, v)
})
}
}
func TestRequest_PriceTemplatesRequestParams(t *testing.T) {
tests := []struct {
name string
input PriceTemplatesRequestParams
expected url.Values
}{
{"Empty", PriceTemplatesRequestParams{}, url.Values{}},
{"Collection", PriceTemplatesRequestParams{Collection: "col"}, url.Values{"collection_name": []string{"col"}}},
{"Schema", PriceTemplatesRequestParams{Schema: "val"}, url.Values{"schema_name": []string{"val"}}},
{"TemplateID", PriceTemplatesRequestParams{TemplateID: 1234}, url.Values{"template_id": []string{"1234"}}},
{"Burned", PriceTemplatesRequestParams{Burned: true}, url.Values{"burned": []string{"true"}}},
{"Symbol", PriceTemplatesRequestParams{Symbol: "WAX"}, url.Values{"symbol": []string{"WAX"}}},
{"Page", PriceTemplatesRequestParams{Page: 5}, url.Values{"page": []string{"5"}}},
{"Limit", PriceTemplatesRequestParams{Limit: 1}, url.Values{"limit": []string{"1"}}},
{"Order", PriceTemplatesRequestParams{Order: SortAscending}, url.Values{"order": []string{"asc"}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v, err := qs.NewEncoder().Values(tt.input)
assert.NoError(t, err)
assert.EqualValues(t, tt.expected, v)
})
}
}
func TestRequest_PriceAssetsRequestParams(t *testing.T) {
tests := []struct {
name string
input PriceAssetsRequestParams
expected url.Values
}{
{"Empty", PriceAssetsRequestParams{}, url.Values{}},
{"Collection", PriceAssetsRequestParams{CollectionName: "col"}, url.Values{"collection_name": []string{"col"}}},
{"Schema", PriceAssetsRequestParams{SchemaName: "val"}, url.Values{"schema_name": []string{"val"}}},
{"TemplateID", PriceAssetsRequestParams{TemplateID: 1234}, url.Values{"template_id": []string{"1234"}}},
{"Owner", PriceAssetsRequestParams{Owner: "val"}, url.Values{"owner": []string{"val"}}},
{"Search", PriceAssetsRequestParams{Search: "val"}, url.Values{"search": []string{"val"}}},
{"MatchImmutableName", PriceAssetsRequestParams{MatchImmutableName: "val"}, url.Values{"match_immutable_name": []string{"val"}}},
{"MatchMutableName", PriceAssetsRequestParams{MatchMutableName: "val"}, url.Values{"match_mutable_name": []string{"val"}}},
{"IsTransferable", PriceAssetsRequestParams{IsTransferable: true}, url.Values{"is_transferable": []string{"true"}}},
{"IsBurnable", PriceAssetsRequestParams{IsBurnable: true}, url.Values{"is_burnable": []string{"true"}}},
{"Burned", PriceAssetsRequestParams{Burned: true}, url.Values{"burned": []string{"true"}}},
{"Minter", PriceAssetsRequestParams{Minter: "alice"}, url.Values{"minter": []string{"alice"}}},
{"InitialReceiver", PriceAssetsRequestParams{InitialReceiver: "bob"}, url.Values{"initial_receiver": []string{"bob"}}},
{"HideOffers", PriceAssetsRequestParams{HideOffers: true}, url.Values{"hide_offers": []string{"true"}}},
{"Ids", PriceAssetsRequestParams{Ids: []string{"1", "2"}}, url.Values{"ids": []string{"1,2"}}},
{"LowerBound", PriceAssetsRequestParams{LowerBound: "100"}, url.Values{"lower_bound": []string{"100"}}},
{"UpperBound", PriceAssetsRequestParams{UpperBound: "200"}, url.Values{"upper_bound": []string{"200"}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v, err := qs.NewEncoder().Values(tt.input)
assert.NoError(t, err)
assert.EqualValues(t, tt.expected, v)
})
}
}
func TestRequest_PriceInventoryRequestParams(t *testing.T) {
tests := []struct {
name string
input PriceInventoryRequestParams
expected url.Values
}{
{"Empty", PriceInventoryRequestParams{}, url.Values{}},
{"Collection", PriceInventoryRequestParams{CollectionName: "col"}, url.Values{"collection_name": []string{"col"}}},
{"Schema", PriceInventoryRequestParams{SchemaName: "val"}, url.Values{"schema_name": []string{"val"}}},
{"TemplateID", PriceInventoryRequestParams{TemplateID: 1234}, url.Values{"template_id": []string{"1234"}}},
{"Owner", PriceInventoryRequestParams{Owner: "val"}, url.Values{"owner": []string{"val"}}},
{"Search", PriceInventoryRequestParams{Search: "val"}, url.Values{"search": []string{"val"}}},
{"MatchImmutableName", PriceInventoryRequestParams{MatchImmutableName: "val"}, url.Values{"match_immutable_name": []string{"val"}}},
{"MatchMutableName", PriceInventoryRequestParams{MatchMutableName: "val"}, url.Values{"match_mutable_name": []string{"val"}}},
{"IsTransferable", PriceInventoryRequestParams{IsTransferable: true}, url.Values{"is_transferable": []string{"true"}}},
{"IsBurnable", PriceInventoryRequestParams{IsBurnable: true}, url.Values{"is_burnable": []string{"true"}}},
{"Burned", PriceInventoryRequestParams{Burned: true}, url.Values{"burned": []string{"true"}}},
{"Minter", PriceInventoryRequestParams{Minter: "alice"}, url.Values{"minter": []string{"alice"}}},
{"InitialReceiver", PriceInventoryRequestParams{InitialReceiver: "bob"}, url.Values{"initial_receiver": []string{"bob"}}},
{"HideOffers", PriceInventoryRequestParams{HideOffers: true}, url.Values{"hide_offers": []string{"true"}}},
{"Ids", PriceInventoryRequestParams{Ids: []string{"1", "2"}}, url.Values{"ids": []string{"1,2"}}},
{"LowerBound", PriceInventoryRequestParams{LowerBound: "100"}, url.Values{"lower_bound": []string{"100"}}},
{"UpperBound", PriceInventoryRequestParams{UpperBound: "200"}, url.Values{"upper_bound": []string{"200"}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v, err := qs.NewEncoder().Values(tt.input)
assert.NoError(t, err)
assert.EqualValues(t, tt.expected, v)
})
}
}