Skip to content

Commit

Permalink
add integration tests for checking zero value url search params
Browse files Browse the repository at this point in the history
  • Loading branch information
atreya2011 committed Apr 27, 2021
1 parent f45eeeb commit a64e415
Show file tree
Hide file tree
Showing 5 changed files with 513 additions and 86 deletions.
5 changes: 5 additions & 0 deletions integration_tests/integration_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ describe("test grpc-gateway-ts communication", () => {
const result = await CounterService.HTTPGetWithURLSearchParams({a: 10, [getFieldName('post_req')]: {b: 0}, c: [23, 25], [getFieldName('ext_msg')]: {d: 12}}, {pathPrefix: "http://localhost:8081"})
expect(getField(result, 'url_search_params_result')).to.equal(70)
})

it('http get request with zero value url search parameters', async () => {
const result = await CounterService.HTTPGetWithZeroValueURLSearchParams({ a: 10, [getFieldName('zero_value_msg')]: { b: false, c: 0, d: "" } }, {pathPrefix: "http://localhost:8081"})
expect(getField(result, 'zero_value_msg')).to.deep.equal({b: true, c: 1, d: "hello"})
})
})
10 changes: 10 additions & 0 deletions integration_tests/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,13 @@ func (r *RealCounterService) HTTPGetWithURLSearchParams(ctx context.Context, in
UrlSearchParamsResult: in.GetA() + in.PostReq.GetB() + in.ExtMsg.GetD() + int32(totalC),
}, nil
}

func (r *RealCounterService) HTTPGetWithZeroValueURLSearchParams(ctx context.Context, in *HTTPGetWithZeroValueURLSearchParamsRequest) (*HTTPGetWithZeroValueURLSearchParamsResponse, error) {
return &HTTPGetWithZeroValueURLSearchParamsResponse{
ZeroValueMsg: &ZeroValueMsg{
B: !in.ZeroValueMsg.GetB(),
C: in.ZeroValueMsg.GetC() + 1,
D: in.ZeroValueMsg.GetD() + "hello",
},
}, nil
}
Loading

0 comments on commit a64e415

Please sign in to comment.