mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-18 15:15:08 +08:00
feat: align Go/Node DSML tool-call parsing drift tolerance and update API docs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -39,6 +40,31 @@ func TestBuildUploadMultipartBodyOmitsPurposeAndIncludesFilePart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDoUploadDoesNotFallbackForNonIdempotentUpload(t *testing.T) {
|
||||
var fallbackCalled bool
|
||||
client := &Client{}
|
||||
_, err := client.doUpload(
|
||||
context.Background(),
|
||||
doerFunc(func(req *http.Request) (*http.Response, error) {
|
||||
_, _ = io.ReadAll(req.Body)
|
||||
return nil, errors.New("ambiguous upload write failure")
|
||||
}),
|
||||
doerFunc(func(*http.Request) (*http.Response, error) {
|
||||
fallbackCalled = true
|
||||
return &http.Response{StatusCode: http.StatusOK, Header: make(http.Header), Body: io.NopCloser(strings.NewReader("{}"))}, nil
|
||||
}),
|
||||
dsprotocol.DeepSeekUploadFileURL,
|
||||
map[string]string{"Content-Type": "multipart/form-data"},
|
||||
[]byte("body"),
|
||||
)
|
||||
if err == nil {
|
||||
t.Fatal("expected upload error")
|
||||
}
|
||||
if fallbackCalled {
|
||||
t.Fatal("upload fallback should not be called for a non-idempotent request")
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractUploadFileResultSupportsNestedShapes(t *testing.T) {
|
||||
got := extractUploadFileResult(map[string]any{
|
||||
"data": map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user