forked from michimani/gotwi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth1_test.go
64 lines (60 loc) · 1.56 KB
/
oauth1_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
package gotwi_test
import (
"testing"
"github.com/michimani/gotwi"
"github.com/stretchr/testify/assert"
)
func Test_EndpointDetail(t *testing.T) {
cases := []struct {
name string
endpoint gotwi.Endpoint
expect *gotwi.EndpointInfo
}{
{
name: "ok",
endpoint: "endpoint",
expect: &gotwi.EndpointInfo{
Raw: "endpoint",
Base: "endpoint",
EncodedQueryParameterMap: map[string]string{},
},
},
{
name: "ok with some parameters",
endpoint: "endpoint?key1=value1&key2=value2",
expect: &gotwi.EndpointInfo{
Raw: "endpoint?key1=value1&key2=value2",
Base: "endpoint",
EncodedQueryParameterMap: map[string]string{
"key1": "value1",
"key2": "value2",
},
},
},
{
name: "ok with encoded parameter",
endpoint: "endpoint?key1=value1&key2=value2&key3=value%20value3",
expect: &gotwi.EndpointInfo{
Raw: "endpoint?key1=value1&key2=value2&key3=value%20value3",
Base: "endpoint",
EncodedQueryParameterMap: map[string]string{
"key1": "value1",
"key2": "value2",
"key3": "value value3",
},
},
},
}
for _, c := range cases {
t.Run(c.name, func(tt *testing.T) {
ed, err := c.endpoint.Detail()
assert.NoError(tt, err)
assert.Equal(tt, c.expect.Raw, ed.Raw)
assert.Equal(tt, c.expect.Base, ed.Base)
assert.Equal(tt, len(c.expect.EncodedQueryParameterMap), len(ed.EncodedQueryParameterMap))
for k, v := range c.expect.EncodedQueryParameterMap {
assert.Equal(tt, v, ed.EncodedQueryParameterMap[k])
}
})
}
}