forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params_test.go
43 lines (36 loc) · 917 Bytes
/
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
package stripe_test
import (
"net/url"
"reflect"
"testing"
stripe "github.com/stripe/stripe-go"
)
func TestParamsWithExtras(t *testing.T) {
testCases := []struct {
InitialBody url.Values
Extras [][2]string
ExpectedBody url.Values
}{
{
InitialBody: url.Values{"foo": {"bar"}},
Extras: [][2]string{},
ExpectedBody: url.Values{"foo": {"bar"}},
},
{
InitialBody: url.Values{"foo": {"bar"}},
Extras: [][2]string{{"foo", "baz"}, {"other", "thing"}},
ExpectedBody: url.Values{"foo": {"bar", "baz"}, "other": {"thing"}},
},
}
for _, testCase := range testCases {
p := stripe.Params{}
for _, extra := range testCase.Extras {
p.AddExtra(extra[0], extra[1])
}
body := testCase.InitialBody
p.AppendTo(&body)
if !reflect.DeepEqual(body, testCase.ExpectedBody) {
t.Fatalf("Expected body of %v but got %v.", testCase.ExpectedBody, body)
}
}
}