-
Notifications
You must be signed in to change notification settings - Fork 0
/
esa_test.go
48 lines (45 loc) · 930 Bytes
/
esa_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuildURL(t *testing.T) {
t.Parallel()
tests := []struct {
url string
opts []QueryOption
expectErr error
expectRet string
}{
{
url: "github.com",
opts: nil,
expectErr: nil,
expectRet: "github.com",
},
{
url: "https://github.com",
opts: nil,
expectErr: nil,
expectRet: "https://github.com",
},
{
url: "https://github.com",
opts: []QueryOption{
QueryOptionSort("createdAt"),
QueryOptionOrder("asc"),
QueryOptionPage(1),
QueryOptionPerPage(50),
},
expectErr: nil,
expectRet: "https://github.com?order=asc&page=1&per_page=50&sort=createdAt",
},
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
ret, err := buildURL(tt.url, tt.opts...)
assert.Equal(t, tt.expectErr, err)
assert.Equal(t, tt.expectRet, ret)
})
}
}