fix: wrap Notable record fields payload

This commit is contained in:
姚章浩
2026-07-23 18:55:03 +08:00
parent 0a3f62618e
commit e582d851a4
2 changed files with 25 additions and 3 deletions
+19 -1
View File
@@ -55,10 +55,28 @@ func TestInsertRecordMethodPathHeaderBody(t *testing.T) {
gotQuery = r.URL.RawQuery
gotToken = r.Header.Get("x-acs-dingtalk-access-token")
var body insertRecordReq
var body map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
t.Errorf("decode body: %v", err)
}
records, ok := body["records"].([]interface{})
if !ok || len(records) != 1 {
t.Errorf("records must contain exactly one record: %#v", body["records"])
} else {
record, ok := records[0].(map[string]interface{})
if !ok {
t.Errorf("record must be an object: %#v", records[0])
} else {
fields, ok := record["fields"].(map[string]interface{})
if !ok {
t.Errorf("record must wrap values in a fields object: %#v", record)
} else if len(record) != 1 {
t.Errorf("record must contain only fields, got keys: %#v", record)
} else if _, ok := fields[FieldOriginalQuestion]; !ok {
t.Errorf("nested fields missing original question field")
}
}
}
raw, _ := json.Marshal(body)
gotBody = string(raw)