Increase code coverage
vaskoz opened this issue · 1 comments
vaskoz commented
Issue Summary
Current code coverage is 91.2%. We can do better.
Steps to Reproduce
go test -v ./...
results in the following:
rest git:(master) go test -cover
PASS
coverage: 91.2% of statements
ok github.com/sendgrid/rest 0.045s
This is primarily an improvement. Additional testing did find an unchecked error due to a bad request causing a panic in the library.
The tests added by 8e0c097 resulted in the following panic:
rest git:(8e0c097) go test
--- FAIL: TestBuildBadRequest (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x126288a]
goroutine 7 [running]:
testing.tRunner.func1(0xc4200fe2d0)
/Users/vasko/code/go/src/testing/testing.go:734 +0x29a
panic(0x12af500, 0x14927d0)
/Users/vasko/code/go/src/runtime/panic.go:502 +0x266
github.com/sendgrid/rest.BuildRequestObject(0x1308b2f, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, ...)
/Users/vasko/go/src/github.com/sendgrid/rest/rest.go:79 +0x1aa
github.com/sendgrid/rest.TestBuildBadRequest(0xc4200fe2d0)
/Users/vasko/go/src/github.com/sendgrid/rest/rest_test.go:53 +0x98
testing.tRunner(0xc4200fe2d0, 0x131d240)
/Users/vasko/code/go/src/testing/testing.go:769 +0xc0
created by testing.(*T).Run
/Users/vasko/code/go/src/testing/testing.go:812 +0x2b1
exit status 2
FAIL github.com/sendgrid/rest 0.027s
and the panic was fixed by checking for the error in df76d1a