feat: align receive messages response contract
This commit is contained in:
@@ -184,6 +184,9 @@ func main() {
|
||||
if err := json.Unmarshal(receiveEncoded, &receivePayload); err != nil {
|
||||
fail("tools/call isphere_receive_messages", fmt.Errorf("decode structuredContent %s: %w", receiveEncoded, err))
|
||||
}
|
||||
if receivePayload["ok"] != true {
|
||||
fail("tools/call isphere_receive_messages", fmt.Errorf("ok = %#v, want true", receivePayload["ok"]))
|
||||
}
|
||||
messagesValue, ok := receivePayload["messages"].([]any)
|
||||
if !ok {
|
||||
fail("tools/call isphere_receive_messages", fmt.Errorf("messages missing or not array: %s", receiveEncoded))
|
||||
@@ -321,6 +324,17 @@ func verifyConfiguredReceiveSource(ctx context.Context) (int, int, int, int) {
|
||||
if message["id"] != "msg-fixture-1" || message["text"] != "redacted-report.docx" || message["subject"] != "FILE_TRANSFER_CANCEL" {
|
||||
fail("fixture/assert", fmt.Errorf("unexpected message: %#v", message))
|
||||
}
|
||||
if message["message_id"] != "msg-fixture-1" || message["content_text"] != "redacted-report.docx" || message["content_type"] != "file" || message["source"] != "local_readonly" || message["raw_ref"] != "packetlog_message" {
|
||||
fail("fixture/assert_contract", fmt.Errorf("unexpected contract message fields: %#v", message))
|
||||
}
|
||||
attachments, ok := message["attachments"].([]any)
|
||||
if !ok || len(attachments) != 1 {
|
||||
fail("fixture/assert_contract", fmt.Errorf("attachments = %#v, want one", message["attachments"]))
|
||||
}
|
||||
attachment, ok := attachments[0].(map[string]any)
|
||||
if !ok || attachment["file_id"] != "msg-fixture-1:redacted-report.docx" || attachment["file_name"] != "redacted-report.docx" || attachment["download_ref"] != nil {
|
||||
fail("fixture/assert_contract", fmt.Errorf("unexpected attachment: %#v", attachments[0]))
|
||||
}
|
||||
if message["conversation_id"] != "project-room@conference.imopenfire1-lanzhou|sender@imopenfire1-lanzhou" {
|
||||
fail("fixture/assert", fmt.Errorf("conversation_id = %#v", message["conversation_id"]))
|
||||
}
|
||||
@@ -427,6 +441,17 @@ func verifyConfiguredDirectorySource(ctx context.Context) (int, int, int, int) {
|
||||
if message["id"] != "msg-dir-fixture-1" || message["text"] != "redacted-dir-report.docx" || message["subject"] != "FILE_TRANSFER_CANCEL" {
|
||||
fail("dir_fixture/assert", fmt.Errorf("unexpected message: %#v", message))
|
||||
}
|
||||
if message["message_id"] != "msg-dir-fixture-1" || message["content_text"] != "redacted-dir-report.docx" || message["content_type"] != "file" || message["source"] != "local_readonly" || message["raw_ref"] != "packetlog_message" {
|
||||
fail("dir_fixture/assert_contract", fmt.Errorf("unexpected contract message fields: %#v", message))
|
||||
}
|
||||
attachments, ok := message["attachments"].([]any)
|
||||
if !ok || len(attachments) != 1 {
|
||||
fail("dir_fixture/assert_contract", fmt.Errorf("attachments = %#v, want one", message["attachments"]))
|
||||
}
|
||||
attachment, ok := attachments[0].(map[string]any)
|
||||
if !ok || attachment["file_id"] != "msg-dir-fixture-1:redacted-dir-report.docx" || attachment["file_name"] != "redacted-dir-report.docx" || attachment["download_ref"] != nil {
|
||||
fail("dir_fixture/assert_contract", fmt.Errorf("unexpected attachment: %#v", attachments[0]))
|
||||
}
|
||||
contactCount := verifySearchContacts(ctx, session, "sender", "dir_fixture/call isphere_search_contacts", 1)
|
||||
groupCount := verifySearchGroups(ctx, session, "project", "dir_fixture/call isphere_search_groups", 1)
|
||||
fileCount := verifyReceiveFiles(ctx, session, "dir-report", "dir_fixture/call isphere_receive_files", 1, "msg-dir-fixture-1:redacted-dir-report.docx", "redacted-dir-report.docx")
|
||||
|
||||
Reference in New Issue
Block a user