Files
isphere-ai-bridge/internal/isphere/files_test.go
2026-07-10 00:45:08 +08:00

32 lines
1.2 KiB
Go

package isphere
import (
"reflect"
"testing"
)
func TestListFilesFromMessagesExtractsFileTransferCandidates(t *testing.T) {
messages := []Message{
{ID: "msg-1", ConversationID: "alice@imopenfire1-lanzhou|bob@imopenfire1-lanzhou", Text: "redacted-report.docx", Timestamp: "1783423807000", Subject: "FILE_TRANSFER_CANCEL"},
{ID: "msg-2", ConversationID: "alice@imopenfire1-lanzhou|bob@imopenfire1-lanzhou", Text: "plain chat", Timestamp: "1783423808000"},
{ID: "msg-3", ConversationID: "room@conference.imopenfire1-lanzhou", Text: "redacted-screenshot.png", Timestamp: "1783423809000"},
}
got := ListFilesFromMessages(messages, ListFilesQuery{NameContains: "report", Limit: 10})
want := ListFilesResult{Files: []File{
{
FileID: "msg-1:redacted-report.docx",
MessageID: "msg-1",
ConversationID: "alice@imopenfire1-lanzhou|bob@imopenfire1-lanzhou",
FileName: "redacted-report.docx",
MimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
CreatedAt: "1783423807000",
Source: "local_readonly",
RawRef: "packetlog_file_transfer",
},
}}
if !reflect.DeepEqual(got, want) {
t.Fatalf("ListFilesFromMessages() = %#v, want %#v", got, want)
}
}