feat(osi): 某人全部体检查询 JKTJ00002(T-306)
- osi.QueryHealthChecks(/auto/jktj/query,返回全部体检数组) - contract.HealthCheckRecordSummary:驼峰 idCard(≠最近一次小写 idcard)、checkId 可空 - HTTP 端点 GET /api/health-check/all - 单测含 null checkId 场景;实测端点已部署 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,43 @@ func TestLastHealthCheckDecodesSummaryAndHitsPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryHealthChecksDecodesArrayAndHitsPath(t *testing.T) {
|
||||
var seenPath string
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
seenPath = r.URL.Path
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
// data 为数组=某人全部体检;idCard 驼峰;历史记录 checkId 为 null(脱敏假数据)
|
||||
_, _ = w.Write([]byte(`{"code":"01","message":"操作成功","data":[` +
|
||||
`{"checkId":"CHK-1","checkDate":"2025-06-23","idCard":"TEST-ID","personName":"测试"},` +
|
||||
`{"checkId":null,"checkDate":"2013-06-07","idCard":"TEST-ID","personName":"测试"}]}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
transport, err := NewTransport(TransportConfig{Timeout: time.Second})
|
||||
if err != nil {
|
||||
t.Fatalf("NewTransport: %v", err)
|
||||
}
|
||||
client := NewClient(ClientConfig{BaseURL: server.URL, UserName: "u", Ask: "k", Transport: transport})
|
||||
|
||||
records, result, err := client.QueryHealthChecks(context.Background(), FindHealthCheckQuery{IDCard: "TEST-ID"})
|
||||
if err != nil {
|
||||
t.Fatalf("QueryHealthChecks: %v", err)
|
||||
}
|
||||
if seenPath != "/osi/api/auto/jktj/query" {
|
||||
t.Fatalf("path = %q", seenPath)
|
||||
}
|
||||
if !result.Success || len(records) != 2 {
|
||||
t.Fatalf("records = %d result = %#v", len(records), result)
|
||||
}
|
||||
// 驼峰 idCard 应解出;历史记录 null checkId 解为空串且不报错
|
||||
if records[0].CheckID != "CHK-1" || records[0].IDCard != "TEST-ID" {
|
||||
t.Fatalf("row0 = %#v", records[0])
|
||||
}
|
||||
if records[1].CheckID != "" || records[1].CheckDate != "2013-06-07" {
|
||||
t.Fatalf("row1 (null checkId) = %#v", records[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestListHealthCheckPeopleDecodesRosterAndHitsPath(t *testing.T) {
|
||||
var seenPath string
|
||||
var seenBody map[string]any
|
||||
|
||||
Reference in New Issue
Block a user