move marshaller and unmarshaler into internal pkg (#304) (#325)

This commit is contained in:
渡邉祐一 / Yuichi Watanabe
2023-05-28 10:51:07 +09:00
committed by GitHub
parent 980504b47e
commit 62eb4beed2
12 changed files with 57 additions and 46 deletions

View File

@@ -7,6 +7,7 @@ import (
"net/http"
"testing"
utils "github.com/sashabaranov/go-openai/internal"
"github.com/sashabaranov/go-openai/internal/test"
"github.com/sashabaranov/go-openai/internal/test/checks"
)
@@ -33,7 +34,7 @@ func (b *failingErrorBuffer) Bytes() []byte {
return []byte{}
}
func (*failingUnMarshaller) unmarshal(_ []byte, _ any) error {
func (*failingUnMarshaller) Unmarshal(_ []byte, _ any) error {
return errTestUnmarshalerFailed
}
@@ -62,7 +63,7 @@ func TestErrorAccumulatorReturnsUnmarshalerErrors(t *testing.T) {
func TestErrorByteWriteErrors(t *testing.T) {
accumulator := &defaultErrorAccumulator{
buffer: &failingErrorBuffer{},
unmarshaler: &jsonUnmarshaler{},
unmarshaler: &utils.JSONUnmarshaler{},
}
err := accumulator.write([]byte("{"))
if !errors.Is(err, errTestErrorAccumulatorWriteFailed) {
@@ -91,7 +92,7 @@ func TestErrorAccumulatorWriteErrors(t *testing.T) {
stream.errAccumulator = &defaultErrorAccumulator{
buffer: &failingErrorBuffer{},
unmarshaler: &jsonUnmarshaler{},
unmarshaler: &utils.JSONUnmarshaler{},
}
_, err = stream.Recv()