Files
CLIProxyAPI/internal/translator/codex/interactions/noop_optimization_test.go
Luis Pater 6e6afab99a refactor: migrate gjson, sjson, and base64 to MoeForge/moego
- Replace tidwall/gjson and tidwall/sjson with github.com/MoeForge/moego/ojson
  and encoding/base64 with github.com/MoeForge/moego/base64 across the main
  module and examples
- Introduce cross-method *ojson.Doc request rewriting pipelines across
  thinking, signature, client/codex, runtime/executor/helps, pluginhost, and
  all provider executors with FinalizePayloadDoc as the final semantic barrier
- Convert all consecutive JSON mutations (>= 2 Set/SetRaw/Delete operations)
  to batch edits on ojson.Doc
- Upgrade read-only byte paths to ojson.GetBytesNoCopy,
  ojson.GetManyBytesNoCopy, and util.ParseGJSONBytesNoCopy with explicit
  strings.Clone ownership protection across streaming and persistent state
- Use base64.StdEncoding.ValidateString for zero-allocation signature checks
  and base64.EncodeDataURL for single-allocation data URL construction
2026-11-03 03:05:04 +08:00

30 lines
855 B
Go

package interactions
import (
"testing"
"github.com/MoeForge/moego/ojson"
"github.com/router-for-me/CLIProxyAPI/v8/internal/util"
)
func TestCleanedCodexToolParametersPreservesCanonicalSchema(t *testing.T) {
input := []byte(`{"type":"object","properties":{"value":{"type":"string"}},"additionalProperties":false}`)
output := []byte(cleanedCodexToolParameters(util.ParseGJSONBytesNoCopy(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 := ojson.Parse(`"auto"`)
output := setInteractionsCodexRawIfDifferent(input, "tool_choice", value)
if &output[0] != &input[0] {
t.Fatal("matching raw value caused a payload copy")
}
}