mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-11 03:37:40 +08:00
37 lines
875 B
Go
37 lines
875 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"ds2api/internal/auth"
|
|
)
|
|
|
|
func TestCallCompletionDoesNotFallbackForNonIdempotentCompletion(t *testing.T) {
|
|
var fallbackCalled bool
|
|
client := &Client{
|
|
stream: doerFunc(func(*http.Request) (*http.Response, error) {
|
|
return nil, errors.New("ambiguous completion write failure")
|
|
}),
|
|
fallbackS: &http.Client{Transport: roundTripperFunc(func(*http.Request) (*http.Response, error) {
|
|
fallbackCalled = true
|
|
return &http.Response{StatusCode: http.StatusOK}, nil
|
|
})},
|
|
}
|
|
_, err := client.CallCompletion(
|
|
context.Background(),
|
|
&auth.RequestAuth{DeepSeekToken: "token"},
|
|
map[string]any{"prompt": "hello"},
|
|
"pow",
|
|
3,
|
|
)
|
|
if err == nil {
|
|
t.Fatal("expected completion error")
|
|
}
|
|
if fallbackCalled {
|
|
t.Fatal("completion fallback should not be called for a non-idempotent request")
|
|
}
|
|
}
|