| 1157 | } |
| 1158 | |
| 1159 | func TestChat_MultipleFiles(t *testing.T) { |
| 1160 | t.Parallel() |
| 1161 | |
| 1162 | now := dbtime.Now() |
| 1163 | file1 := uuid.New() |
| 1164 | file2 := uuid.New() |
| 1165 | |
| 1166 | chat := database.Chat{ |
| 1167 | ID: uuid.New(), |
| 1168 | OwnerID: uuid.New(), |
| 1169 | LastModelConfigID: uuid.New(), |
| 1170 | Title: "multi file test", |
| 1171 | Status: database.ChatStatusWaiting, |
| 1172 | CreatedAt: now, |
| 1173 | UpdatedAt: now, |
| 1174 | } |
| 1175 | |
| 1176 | rows := []database.GetChatFileMetadataByChatIDRow{ |
| 1177 | { |
| 1178 | ID: file1, |
| 1179 | OwnerID: chat.OwnerID, |
| 1180 | OrganizationID: uuid.New(), |
| 1181 | Name: "a.png", |
| 1182 | Mimetype: "image/png", |
| 1183 | CreatedAt: now, |
| 1184 | }, |
| 1185 | { |
| 1186 | ID: file2, |
| 1187 | OwnerID: chat.OwnerID, |
| 1188 | OrganizationID: uuid.New(), |
| 1189 | Name: "b.txt", |
| 1190 | Mimetype: "text/plain", |
| 1191 | CreatedAt: now, |
| 1192 | }, |
| 1193 | } |
| 1194 | |
| 1195 | result := db2sdk.Chat(chat, nil, rows) |
| 1196 | require.Len(t, result.Files, 2) |
| 1197 | require.Equal(t, "a.png", result.Files[0].Name) |
| 1198 | require.Equal(t, "b.txt", result.Files[1].Name) |
| 1199 | } |
| 1200 | |
| 1201 | func TestChatQueuedMessage_MalformedContent(t *testing.T) { |
| 1202 | t.Parallel() |