fix(osi): 校准机构查询请求契约

This commit is contained in:
ila
2026-07-13 20:02:19 +08:00
parent d60b979785
commit d30ff01c35
6 changed files with 44 additions and 13 deletions
+25 -2
View File
@@ -132,7 +132,7 @@ func TestQueryOrgsCallsCXJG00002(t *testing.T) {
if err := json.NewDecoder(r.Body).Decode(&seenPayload); err != nil {
t.Fatalf("decode request: %v", err)
}
_, _ = w.Write([]byte(`{"code":"01","message":"操作成功","data":[{"organizCode":"441625001","organizName":"测试机构","organizType":"1","parentId":"441625"}]}`))
_, _ = w.Write([]byte(`{"code":"01","message":"操作成功","data":[{"organizCode":"441625001","organizName":"测试机构","organizType":"1","parentId":"441625","regionCode":"441625000000"}]}`))
}))
defer server.Close()
@@ -157,7 +157,30 @@ func TestQueryOrgsCallsCXJG00002(t *testing.T) {
if baseInfo["organizCode"] != "441625001" || baseInfo["parentId"] != "441625" {
t.Fatalf("baseInfo = %#v", baseInfo)
}
if len(rows) != 1 || rows[0].OrganizCode != "441625001" || rows[0].OrganizName != "测试机构" || rows[0].OrganizType != "1" || rows[0].ParentID != "441625" {
if len(rows) != 1 || rows[0].OrganizCode != "441625001" || rows[0].OrganizName != "测试机构" || rows[0].OrganizType != "1" || rows[0].ParentID != "441625" || rows[0].RegionCode != "441625000000" {
t.Fatalf("rows = %#v", rows)
}
}
func TestQueryOrgsSendsEmptyRequiredKeys(t *testing.T) {
var seenPayload map[string]any
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if err := json.NewDecoder(r.Body).Decode(&seenPayload); err != nil {
t.Fatalf("decode request: %v", err)
}
_, _ = w.Write([]byte(`{"code":"01","message":"操作成功","data":[]}`))
}))
defer server.Close()
client := newTestJKDAClient(t, server.URL)
if _, _, err := client.QueryOrgs(context.Background(), OrgQuery{}); err != nil {
t.Fatalf("QueryOrgs: %v", err)
}
baseInfo := seenPayload["uploadinfo"].(map[string]any)["baseInfo"].(map[string]any)
if _, ok := baseInfo["organizCode"]; !ok || baseInfo["organizCode"] != "" {
t.Fatalf("organizCode should be present and empty: %#v", baseInfo)
}
if _, ok := baseInfo["parentId"]; !ok || baseInfo["parentId"] != "" {
t.Fatalf("parentId should be present and empty: %#v", baseInfo)
}
}