-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
param_test.go
61 lines (56 loc) · 1.52 KB
/
param_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
package sdkclient_test
import (
"testing"
"github.com/aws/aws-sdk-go-v2/aws"
sdkclient "github.com/fujiwara/awslim"
)
type ParamTestCase struct {
Name string
Param *sdkclient.ClientMethodParam
Inject map[string]any
ExpectedJSON string
}
var ParamTestCases = []ParamTestCase{
{
Name: "inject nil",
Param: &sdkclient.ClientMethodParam{
InputBytes: []byte(`{"foo":"bar"}`),
},
Inject: map[string]any{},
ExpectedJSON: `{"foo":"bar"}`,
},
{
Name: "inject int64",
Param: &sdkclient.ClientMethodParam{
InputBytes: []byte(`{"foo": "bar"}`),
},
Inject: map[string]any{"int64": int64(42), "int64p": aws.Int64(42)},
ExpectedJSON: `{"foo":"bar","int64":42,"int64p":42}`,
},
{
Name: "inject string",
Param: &sdkclient.ClientMethodParam{
InputBytes: []byte(`{"foo": "bar"}`),
},
Inject: map[string]any{"string": "baz", "stringp": aws.String("bazzz")},
ExpectedJSON: `{"foo":"bar","string":"baz","stringp":"bazzz"}`,
},
{
Name: "inject bool",
Param: &sdkclient.ClientMethodParam{
InputBytes: []byte(`{"foo": "bar"}`),
},
Inject: map[string]any{"bool": true, "boolp": aws.Bool(false)},
ExpectedJSON: `{"bool":true,"boolp":false,"foo":"bar"}`,
},
}
func TestClientMethodParams(t *testing.T) {
for _, c := range ParamTestCases {
t.Run(c.Name, func(t *testing.T) {
c.Param.MustInject(c.Inject)
if string(c.Param.InputBytes) != c.ExpectedJSON {
t.Errorf("unexpected InputBytes: got %s, want %s", c.Param.InputBytes, c.ExpectedJSON)
}
})
}
}