mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-09-07 00:24:17 +08:00
- Added tests to ensure no-copy payload reuse for various translators (Codex, Gemini, OpenAI, Claude, etc.). - Covered scenarios for field normalization, tool parameter cleaning, and thought signature sanitization. - Included a benchmark for SanitizeGeminiRequestThoughtSignatures with large normalized payloads.
29 lines
781 B
Go
29 lines
781 B
Go
package interactions
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func TestCleanedCodexToolParametersPreservesCanonicalSchema(t *testing.T) {
|
|
input := []byte(`{"type":"object","properties":{"value":{"type":"string"}},"additionalProperties":false}`)
|
|
|
|
output := []byte(cleanedCodexToolParameters(gjson.ParseBytes(input)))
|
|
|
|
if string(output) != string(input) {
|
|
t.Fatalf("canonical schema changed:\n got: %s\nwant: %s", output, input)
|
|
}
|
|
}
|
|
|
|
func TestSetInteractionsCodexRawIfDifferentReusesMatchingValue(t *testing.T) {
|
|
input := []byte(`{"tool_choice":"auto","input":[]}`)
|
|
value := gjson.Parse(`"auto"`)
|
|
|
|
output := setInteractionsCodexRawIfDifferent(input, "tool_choice", value)
|
|
|
|
if &output[0] != &input[0] {
|
|
t.Fatal("matching raw value caused a payload copy")
|
|
}
|
|
}
|