Ai
2 Star 0 Fork 0

ledao/go-openai

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
error_accumulator_test.go 940 Bytes
Copy Edit Raw Blame History
davezhao authored 2024-11-05 19:07 +08:00 . rename
package openai_test
import (
"bytes"
"errors"
"testing"
utils "gitee.com/ledao/go-openai/internal"
"gitee.com/ledao/go-openai/internal/test"
)
func TestErrorAccumulatorBytes(t *testing.T) {
accumulator := &utils.DefaultErrorAccumulator{
Buffer: &bytes.Buffer{},
}
errBytes := accumulator.Bytes()
if len(errBytes) != 0 {
t.Fatalf("Did not return nil with empty bytes: %s", string(errBytes))
}
err := accumulator.Write([]byte("{}"))
if err != nil {
t.Fatalf("%+v", err)
}
errBytes = accumulator.Bytes()
if len(errBytes) == 0 {
t.Fatalf("Did not return error bytes when has error: %s", string(errBytes))
}
}
func TestErrorByteWriteErrors(t *testing.T) {
accumulator := &utils.DefaultErrorAccumulator{
Buffer: &test.FailingErrorBuffer{},
}
err := accumulator.Write([]byte("{"))
if !errors.Is(err, test.ErrTestErrorAccumulatorWriteFailed) {
t.Fatalf("Did not return error when write failed: %v", err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ledao/go-openai.git
git@gitee.com:ledao/go-openai.git
ledao
go-openai
go-openai
v1.0.10

Search