forked from sashabaranov/go-openai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move error_accumulator into internal pkg (sashabaranov#304)
- Loading branch information
Showing
7 changed files
with
127 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package openai //nolint:testpackage // testing private field | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestStreamReaderReturnsUnmarshalerErrors(t *testing.T) { | ||
stream := &streamReader[ChatCompletionStreamResponse]{ | ||
errAccumulator: newErrorAccumulator(), | ||
unmarshaler: &failingUnMarshaller{}, | ||
} | ||
|
||
respErr := stream.unmarshalError() | ||
if respErr != nil { | ||
t.Fatalf("Did not return nil with empty buffer: %v", respErr) | ||
} | ||
|
||
err := stream.errAccumulator.write([]byte("{")) | ||
if err != nil { | ||
t.Fatalf("%+v", err) | ||
} | ||
|
||
respErr = stream.unmarshalError() | ||
if respErr != nil { | ||
t.Fatalf("Did not return nil when unmarshaler failed: %v", respErr) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters