Skip to content

Commit

Permalink
Add test case for issue 219
Browse files Browse the repository at this point in the history
Signed-off-by: Golang Lemonade <[email protected]>
  • Loading branch information
golanglemonade committed Apr 23, 2024
1 parent 8309b96 commit ed9537a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions clientv2/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ func TestMarshalJSONValueType(t *testing.T) {
if !cmp.Equal(tt.want, got) {
t.Errorf("MarshalJSON() = %v, want %v", got, tt.want)
}

})
}
}
Expand All @@ -578,6 +579,13 @@ func TestMarshalJSON(t *testing.T) {
Name string `json:"name"`
Number Number `json:"number"`
}

// example nested struct
type WhereInput struct {
Not *WhereInput `json:"not,omitempty"`
ID *string `json:"id,omitempty"`
}

testDate := time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC)
type args struct {
v any
Expand Down Expand Up @@ -608,6 +616,23 @@ func TestMarshalJSON(t *testing.T) {
},
want: []byte(`{"operationName":"query", "query":"query ($input: Number!) { input }","variables":{"input":"TWO"}}`),
},
{
name: "marshal nested",
args: args{
v: Request{
OperationName: "query",
Query: `query ($input: Number!) { input }`,
Variables: map[string]any{
"where": WhereInput{
Not: &WhereInput{
ID: &[]string{"1"}[0],
},
},
},
},
},
want: []byte(`{"operationName":"query", "query":"query ($input: Number!) { input }","variables":{"where":{"not":{"id":"1"}}}}`),
},
{
name: "marshal a struct with custom marshaler",
args: args{
Expand Down

0 comments on commit ed9537a

Please sign in to comment.