MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / runThinkingTests

Function runThinkingTests

test/thinking_conversion_test.go:3000–3095  ·  view source on GitHub ↗

runThinkingTests runs thinking test cases using the real data flow path.

(t *testing.T, cases []thinkingTestCase)

Source from the content-addressed store, hash-verified

2998
2999// runThinkingTests runs thinking test cases using the real data flow path.
3000func runThinkingTests(t *testing.T, cases []thinkingTestCase) {
3001 for _, tc := range cases {
3002 tc := tc
3003 testName := fmt.Sprintf("Case%s_%s->%s_%s", tc.name, tc.from, tc.to, tc.model)
3004 t.Run(testName, func(t *testing.T) {
3005 suffixResult := thinking.ParseSuffix(tc.model)
3006 baseModel := suffixResult.ModelName
3007
3008 translateTo := tc.to
3009 applyTo := tc.to
3010 switch applyTo {
3011 case "kimi":
3012 translateTo = "openai"
3013 case "xai":
3014 translateTo = "codex"
3015 }
3016
3017 body := sdktranslator.TranslateRequest(
3018 sdktranslator.FromString(tc.from),
3019 sdktranslator.FromString(translateTo),
3020 baseModel,
3021 []byte(tc.inputJSON),
3022 true,
3023 )
3024 if applyTo == "claude" {
3025 body, _ = sjson.SetBytes(body, "max_tokens", 200000)
3026 }
3027
3028 body, err := thinking.ApplyThinking(body, tc.model, tc.from, applyTo, applyTo)
3029
3030 if tc.expectErr {
3031 if err == nil {
3032 t.Fatalf("expected error but got none, body=%s", string(body))
3033 }
3034 return
3035 }
3036 if err != nil {
3037 t.Fatalf("unexpected error: %v, body=%s", err, string(body))
3038 }
3039
3040 if tc.expectField == "" {
3041 var hasThinking bool
3042 switch tc.to {
3043 case "gemini":
3044 hasThinking = gjson.GetBytes(body, "generationConfig.thinkingConfig").Exists()
3045 case "antigravity":
3046 hasThinking = gjson.GetBytes(body, "request.generationConfig.thinkingConfig").Exists()
3047 case "claude":
3048 hasThinking = gjson.GetBytes(body, "thinking").Exists()
3049 case "openai":
3050 hasThinking = gjson.GetBytes(body, "reasoning_effort").Exists()
3051 case "codex":
3052 hasThinking = gjson.GetBytes(body, "reasoning.effort").Exists() || gjson.GetBytes(body, "reasoning").Exists()
3053 }
3054 if hasThinking {
3055 t.Fatalf("expected no thinking field but found one, body=%s", string(body))
3056 }
3057 return

Calls 5

ParseSuffixFunction · 0.92
ApplyThinkingFunction · 0.92
RunMethod · 0.80
TranslateRequestMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected