-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathutil_test.go
36 lines (34 loc) · 896 Bytes
/
util_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
package blockfrost
import (
"net/http"
"testing"
)
func TestFormatParams(t *testing.T) {
tests := []struct {
query APIQueryParams
want string
}{
{APIQueryParams{Count: 5}, "count=5"},
{APIQueryParams{Page: 10}, "page=10"},
{APIQueryParams{}, ""},
{APIQueryParams{Order: "asc"}, "order=asc"},
{APIQueryParams{Count: 5, Page: 10}, "count=5&page=10"},
{APIQueryParams{Count: 5, Page: 10, Order: "desc"}, "count=5&order=desc&page=10"},
{APIQueryParams{From: "8929261"}, "from=8929261"},
{APIQueryParams{To: "9999269:10"}, "to=9999269%3A10"},
}
req, err := http.NewRequest(http.MethodGet, "/go", nil)
if err != nil {
t.Fatal(err)
}
for _, tt := range tests {
tt, want := tt, tt.want
v := req.URL.Query()
t.Run("", func(t *testing.T) {
got := formatParams(v, tt.query).Encode()
if got != want {
t.Fatalf("expected %s got %s", want, got)
}
})
}
}