test: add tests for errors

This commit is contained in:
mehanizm
2020-04-17 23:12:07 +03:00
parent bc37bb1eb4
commit 4630f5f396
4 changed files with 38 additions and 7 deletions

View File

@@ -25,9 +25,13 @@ func TestClient_do(t *testing.T) {
if err != nil {
log.Fatal(err)
}
err = c.do(req, url, nil)
err = c.do(req, nil)
var e *HTTPClientError
if errors.Is(err, e) {
t.Errorf("should be an http error, but was not: %v", err)
}
err = c.do(nil, nil)
if err == nil {
t.Errorf("there should be an error, but was nil")
}
}