Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
75e7c3dd
"git@web.lueluesay.top:chenxi/sub2api.git" did not exist on "6a2cf09ee05ff4833c93592f6c68cf21415febde"
Commit
75e7c3dd
authored
Jan 03, 2026
by
ianshaw
Browse files
fix(test): 修复测试文件与函数签名不匹配问题
parent
691e2767
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/pkg/antigravity/request_transformer_test.go
View file @
75e7c3dd
...
@@ -8,11 +8,11 @@ import (
...
@@ -8,11 +8,11 @@ import (
// TestBuildParts_ThinkingBlockWithoutSignature 测试thinking block无signature时的处理
// TestBuildParts_ThinkingBlockWithoutSignature 测试thinking block无signature时的处理
func
TestBuildParts_ThinkingBlockWithoutSignature
(
t
*
testing
.
T
)
{
func
TestBuildParts_ThinkingBlockWithoutSignature
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
content
string
content
string
thoughtMode
thoughtSignatureMode
allowDummyThought
bool
expectedParts
int
expectedParts
int
description
string
description
string
}{
}{
{
{
name
:
"Claude model - drop thinking without signature"
,
name
:
"Claude model - drop thinking without signature"
,
...
@@ -21,9 +21,9 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
...
@@ -21,9 +21,9 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
{"type": "thinking", "thinking": "Let me think...", "signature": ""},
{"type": "thinking", "thinking": "Let me think...", "signature": ""},
{"type": "text", "text": "World"}
{"type": "text", "text": "World"}
]`
,
]`
,
thoughtMode
:
thoughtSignatureModePreserv
e
,
allowDummyThought
:
fals
e
,
expectedParts
:
2
,
// thinking 内容被丢弃
expectedParts
:
2
,
// thinking 内容被丢弃
description
:
"Claude模型应丢弃无signature的thinking block内容"
,
description
:
"Claude模型应丢弃无signature的thinking block内容"
,
},
},
{
{
name
:
"Claude model - preserve thinking block with signature"
,
name
:
"Claude model - preserve thinking block with signature"
,
...
@@ -32,9 +32,9 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
...
@@ -32,9 +32,9 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
{"type": "thinking", "thinking": "Let me think...", "signature": "sig_real_123"},
{"type": "thinking", "thinking": "Let me think...", "signature": "sig_real_123"},
{"type": "text", "text": "World"}
{"type": "text", "text": "World"}
]`
,
]`
,
thoughtMode
:
thoughtSignatureModePreserv
e
,
allowDummyThought
:
fals
e
,
expectedParts
:
3
,
expectedParts
:
3
,
description
:
"Claude模型应透传带 signature 的 thinking block(用于 Vertex 签名链路)"
,
description
:
"Claude模型应透传带 signature 的 thinking block(用于 Vertex 签名链路)"
,
},
},
{
{
name
:
"Gemini model - use dummy signature"
,
name
:
"Gemini model - use dummy signature"
,
...
@@ -43,27 +43,16 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
...
@@ -43,27 +43,16 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
{"type": "thinking", "thinking": "Let me think...", "signature": ""},
{"type": "thinking", "thinking": "Let me think...", "signature": ""},
{"type": "text", "text": "World"}
{"type": "text", "text": "World"}
]`
,
]`
,
thoughtMode
:
thoughtSignatureModeDummy
,
allowDummyThought
:
true
,
expectedParts
:
3
,
// 三个block都保留,thinking使用dummy signature
expectedParts
:
3
,
// 三个block都保留,thinking使用dummy signature
description
:
"Gemini模型应该为无signature的thinking block使用dummy signature"
,
description
:
"Gemini模型应该为无signature的thinking block使用dummy signature"
,
},
{
name
:
"Claude model - signature-only thinking block becomes signature-only part"
,
content
:
`[
{"type": "text", "text": "Hello"},
{"type": "thinking", "thinking": "", "signature": "sig_only_456"},
{"type": "text", "text": "World"}
]`
,
thoughtMode
:
thoughtSignatureModePreserve
,
expectedParts
:
3
,
description
:
"Claude模型应将空 thinking + signature 映射为 signature-only part,便于 roundtrip"
,
},
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
toolIDToName
:=
make
(
map
[
string
]
string
)
toolIDToName
:=
make
(
map
[
string
]
string
)
parts
,
err
:=
buildParts
(
json
.
RawMessage
(
tt
.
content
),
toolIDToName
,
tt
.
t
hought
Mode
)
parts
,
err
:=
buildParts
(
json
.
RawMessage
(
tt
.
content
),
toolIDToName
,
tt
.
allowDummyT
hought
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"buildParts() error = %v"
,
err
)
t
.
Fatalf
(
"buildParts() error = %v"
,
err
)
...
@@ -82,14 +71,6 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
...
@@ -82,14 +71,6 @@ func TestBuildParts_ThinkingBlockWithoutSignature(t *testing.T) {
t
.
Fatalf
(
"expected thought part with signature sig_real_123, got thought=%v signature=%q"
,
t
.
Fatalf
(
"expected thought part with signature sig_real_123, got thought=%v signature=%q"
,
parts
[
1
]
.
Thought
,
parts
[
1
]
.
ThoughtSignature
)
parts
[
1
]
.
Thought
,
parts
[
1
]
.
ThoughtSignature
)
}
}
case
"Claude model - signature-only thinking block becomes signature-only part"
:
if
len
(
parts
)
!=
3
{
t
.
Fatalf
(
"expected 3 parts, got %d"
,
len
(
parts
))
}
if
parts
[
1
]
.
Thought
||
parts
[
1
]
.
Text
!=
""
||
parts
[
1
]
.
ThoughtSignature
!=
"sig_only_456"
{
t
.
Fatalf
(
"expected signature-only part, got thought=%v text=%q signature=%q"
,
parts
[
1
]
.
Thought
,
parts
[
1
]
.
Text
,
parts
[
1
]
.
ThoughtSignature
)
}
case
"Gemini model - use dummy signature"
:
case
"Gemini model - use dummy signature"
:
if
len
(
parts
)
!=
3
{
if
len
(
parts
)
!=
3
{
t
.
Fatalf
(
"expected 3 parts, got %d"
,
len
(
parts
))
t
.
Fatalf
(
"expected 3 parts, got %d"
,
len
(
parts
))
...
@@ -108,31 +89,32 @@ func TestBuildParts_ToolUseSignatureHandling(t *testing.T) {
...
@@ -108,31 +89,32 @@ func TestBuildParts_ToolUseSignatureHandling(t *testing.T) {
{"type": "tool_use", "id": "t1", "name": "Bash", "input": {"command": "ls"}, "signature": "sig_tool_abc"}
{"type": "tool_use", "id": "t1", "name": "Bash", "input": {"command": "ls"}, "signature": "sig_tool_abc"}
]`
]`
t
.
Run
(
"
Claude preserve
tool_use signature"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Gemini uses dummy
tool_use signature"
,
func
(
t
*
testing
.
T
)
{
toolIDToName
:=
make
(
map
[
string
]
string
)
toolIDToName
:=
make
(
map
[
string
]
string
)
parts
,
err
:=
buildParts
(
json
.
RawMessage
(
content
),
toolIDToName
,
t
houghtSignatureModePreserv
e
)
parts
,
err
:=
buildParts
(
json
.
RawMessage
(
content
),
toolIDToName
,
t
ru
e
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"buildParts() error = %v"
,
err
)
t
.
Fatalf
(
"buildParts() error = %v"
,
err
)
}
}
if
len
(
parts
)
!=
1
||
parts
[
0
]
.
FunctionCall
==
nil
{
if
len
(
parts
)
!=
1
||
parts
[
0
]
.
FunctionCall
==
nil
{
t
.
Fatalf
(
"expected 1 functionCall part, got %+v"
,
parts
)
t
.
Fatalf
(
"expected 1 functionCall part, got %+v"
,
parts
)
}
}
if
parts
[
0
]
.
ThoughtSignature
!=
"sig_tool_abc"
{
if
parts
[
0
]
.
ThoughtSignature
!=
dummyThoughtSignature
{
t
.
Fatalf
(
"expected tool signature
sig_tool_abc, got %q"
,
parts
[
0
]
.
ThoughtSignature
)
t
.
Fatalf
(
"expected
dummy
tool signature
%q, got %q"
,
dummyThoughtSignature
,
parts
[
0
]
.
ThoughtSignature
)
}
}
})
})
t
.
Run
(
"
Gemini uses dummy tool_use signatur
e"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Claude model - no signature for tool_us
e"
,
func
(
t
*
testing
.
T
)
{
toolIDToName
:=
make
(
map
[
string
]
string
)
toolIDToName
:=
make
(
map
[
string
]
string
)
parts
,
err
:=
buildParts
(
json
.
RawMessage
(
content
),
toolIDToName
,
thoughtSignatureModeDummy
)
parts
,
err
:=
buildParts
(
json
.
RawMessage
(
content
),
toolIDToName
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"buildParts() error = %v"
,
err
)
t
.
Fatalf
(
"buildParts() error = %v"
,
err
)
}
}
if
len
(
parts
)
!=
1
||
parts
[
0
]
.
FunctionCall
==
nil
{
if
len
(
parts
)
!=
1
||
parts
[
0
]
.
FunctionCall
==
nil
{
t
.
Fatalf
(
"expected 1 functionCall part, got %+v"
,
parts
)
t
.
Fatalf
(
"expected 1 functionCall part, got %+v"
,
parts
)
}
}
if
parts
[
0
]
.
ThoughtSignature
!=
dummyThoughtSignature
{
// Claude 模型不设置 signature
t
.
Fatalf
(
"expected dummy tool signature %q, got %q"
,
dummyThoughtSignature
,
parts
[
0
]
.
ThoughtSignature
)
if
parts
[
0
]
.
ThoughtSignature
!=
""
{
t
.
Fatalf
(
"expected no tool signature for Claude, got %q"
,
parts
[
0
]
.
ThoughtSignature
)
}
}
})
})
}
}
...
...
backend/internal/server/api_contract_test.go
View file @
75e7c3dd
...
@@ -310,10 +310,10 @@ func TestAPIContracts(t *testing.T) {
...
@@ -310,10 +310,10 @@ func TestAPIContracts(t *testing.T) {
"default_concurrency": 5,
"default_concurrency": 5,
"default_balance": 1.25,
"default_balance": 1.25,
"enable_model_fallback": false,
"enable_model_fallback": false,
"fallback_model_anthropic": "",
"fallback_model_anthropic": "
claude-3-5-sonnet-20241022
",
"fallback_model_antigravity": "",
"fallback_model_antigravity": "
gemini-2.5-pro
",
"fallback_model_gemini": "",
"fallback_model_gemini": "
gemini-2.5-pro
",
"fallback_model_openai": ""
"fallback_model_openai": "
gpt-4o
"
}
}
}`
,
}`
,
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment