1
0

feat: 系统性改进后端测试体系

- 新增 6 个测试场景 (config load pipe, handler errors, service aggregation, engine degradation, openai decoder edges, negative tests)
- 更新测试工具规格 (mockgen, in-memory SQLite)
- 覆盖率目标从 >80% 提升至 >85%
- 新增 test-unit 和 test-integration Makefile 命令
- 新增死代码清理和 mockgen 需求
- 归档变更至 openspec/changes/archive/2026-04-22-improve-backend-testing/
This commit is contained in:
2026-04-22 13:18:51 +08:00
parent 59179094ed
commit 4e86adffb7
32 changed files with 3374 additions and 729 deletions

View File

@@ -409,3 +409,25 @@ func TestDecodeResponse_Refusal(t *testing.T) {
}
assert.True(t, found)
}
func TestDecodeRequest_AssistantContentArray(t *testing.T) {
body := []byte(`{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "hello"},
{
"role": "assistant",
"content": [{"type": "text", "text": "hello back"}]
}
]
}`)
req, err := decodeRequest(body)
require.NoError(t, err)
assert.Len(t, req.Messages, 2)
assistantMsg := req.Messages[1]
assert.Equal(t, canonical.RoleAssistant, assistantMsg.Role)
assert.Len(t, assistantMsg.Content, 1)
assert.Equal(t, "text", assistantMsg.Content[0].Type)
assert.Equal(t, "hello back", assistantMsg.Content[0].Text)
}