Skip to content

Commit

Permalink
✅ test: add nil jsonDecoder test case (#2139)
Browse files Browse the repository at this point in the history
test: add nil jsonDecoder test case
  • Loading branch information
li-jin-gou committed Oct 5, 2022
1 parent 902e30e commit 00ebb21
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,24 @@ func Test_Client_Agent_Struct(t *testing.T) {
utils.AssertEqual(t, 1, len(errs))
utils.AssertEqual(t, "unexpected end of JSON input", errs[0].Error())
})

t.Run("nil jsonDecoder", func(t *testing.T) {
a := AcquireAgent()
defer ReleaseAgent(a)
defer a.ConnectionClose()
request := a.Request()
request.Header.SetMethod("GET")
request.SetRequestURI("http://example.com")
err := a.Parse()
utils.AssertEqual(t, nil, err)
a.HostClient.Dial = func(addr string) (net.Conn, error) { return ln.Dial() }
var d data
code, body, errs := a.Struct(&d)
utils.AssertEqual(t, StatusOK, code)
utils.AssertEqual(t, `{"success":true}`, string(body))
utils.AssertEqual(t, 0, len(errs))
utils.AssertEqual(t, true, d.Success)
})
}

func Test_Client_Agent_Parse(t *testing.T) {
Expand Down

1 comment on commit 00ebb21

@ReneWerner87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 00ebb21 Previous: 902e30e Ratio
Benchmark_AcquireCtx 1745 ns/op 1568 B/op 5 allocs/op 615.8 ns/op 1568 B/op 5 allocs/op 2.83

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.