Add tests (#171)

* test models listing

* remove non-needed method

* test for .streamFinished

* add more error tests

* improve stream testing

* fix typo
This commit is contained in:
sashabaranov
2023-03-16 19:10:27 +04:00
committed by GitHub
parent fd44d3665e
commit a8acb5f63b
6 changed files with 23 additions and 5 deletions

View File

@@ -141,6 +141,9 @@ func TestAPIError(t *testing.T) {
if *apiErr.Code != "invalid_api_key" {
t.Fatalf("Unexpected API error code: %s", *apiErr.Code)
}
if apiErr.Error() == "" {
t.Fatal("Empty error message occured")
}
}
func TestRequestError(t *testing.T) {
@@ -163,6 +166,10 @@ func TestRequestError(t *testing.T) {
if reqErr.StatusCode != 418 {
t.Fatalf("Unexpected request error status code: %d", reqErr.StatusCode)
}
if reqErr.Unwrap() == nil {
t.Fatalf("Empty request error occured")
}
}
// numTokens Returns the number of GPT-3 encoded tokens in the given text.