Skip to content

Commit 13c65e1

Browse files
danicc097mromaszewicz
authored andcommitted
update tests
1 parent 4dcbfae commit 13c65e1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

deepobject_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type InnerObject2 struct {
2626

2727
type InnerObject3 struct {
2828
Foo string
29-
Count *int
29+
Count *int `json:"count,omitempty"`
3030
}
3131

3232
// These are all possible field types, mandatory and optional.
@@ -65,8 +65,7 @@ func TestDeepObject(t *testing.T) {
6565
}
6666
d := MockBinder{Time: time.Date(2020, 2, 1, 0, 0, 0, 0, time.UTC)}
6767

68-
one := 1
69-
two := 1
68+
two := 2
7069

7170
srcObj := AllFields{
7271
I: 12,
@@ -84,10 +83,10 @@ func TestDeepObject(t *testing.T) {
8483
},
8584
Ao: []InnerObject2{
8685
{Foo: "bar", Is: true},
87-
{Foo: "baz", Is: false},
86+
{Foo: "baz"},
8887
},
8988
Aop: &[]InnerObject3{
90-
{Foo: "a", Count: &one},
89+
{Foo: "a"},
9190
{Foo: "b", Count: &two},
9291
},
9392
Onas: InnerArrayObject{
@@ -102,7 +101,7 @@ func TestDeepObject(t *testing.T) {
102101

103102
marshaled, err := MarshalDeepObject(srcObj, "p")
104103
require.NoError(t, err)
105-
require.EqualValues(t, "p[ab][0]=true&p[ao][0][Foo]=bar&p[ao][0][Is]=true&p[ao][1][Foo]=baz&p[ao][1][Is]=false&p[aop][0][Count]=1&p[aop][0][Foo]=a&p[aop][1][Count]=1&p[aop][1][Foo]=b&p[as][0]=hello&p[as][1]=world&p[b]=true&p[d]=2020-02-01&p[f]=4.2&p[i]=12&p[m][additional]=1&p[o][ID]=456&p[o][Name]=Joe Schmoe&p[oas][0]=foo&p[oas][1]=bar&p[ob]=true&p[od]=2020-02-01&p[of]=3.7&p[oi]=5&p[om][additional]=1&p[onas][names][0]=Bill&p[onas][names][1]=Frank&p[oo][ID]=123&p[oo][Name]=Marcin Romaszewicz", marshaled)
104+
require.EqualValues(t, "p[ab][0]=true&p[ao][0][Foo]=bar&p[ao][0][Is]=true&p[ao][1][Foo]=baz&p[ao][1][Is]=false&p[aop][0][Foo]=a&p[aop][1][Foo]=b&p[aop][1][count]=2&p[as][0]=hello&p[as][1]=world&p[b]=true&p[d]=2020-02-01&p[f]=4.2&p[i]=12&p[m][additional]=1&p[o][ID]=456&p[o][Name]=Joe Schmoe&p[oas][0]=foo&p[oas][1]=bar&p[ob]=true&p[od]=2020-02-01&p[of]=3.7&p[oi]=5&p[om][additional]=1&p[onas][names][0]=Bill&p[onas][names][1]=Frank&p[oo][ID]=123&p[oo][Name]=Marcin Romaszewicz", marshaled)
106105

107106
params := make(url.Values)
108107
marshaledParts := strings.Split(marshaled, "&")

0 commit comments

Comments
 (0)