| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "reasonix/internal/attachment" |
| 8 | "reasonix/internal/provider" |
| 9 | "reasonix/internal/sessioncontent" |
| 10 | ) |
| 11 | |
| 12 | func TestHistoryMessagesIncludeSessionAttachments(t *testing.T) { |
| 13 | digest := strings.Repeat("ab", 32) |
| 14 | msgs := []provider.Message{{ |
| 15 | Role: provider.RoleUser, |
| 16 | Content: "look", |
| 17 | ImageInputs: []attachment.ImageInput{{ |
| 18 | Kind: attachment.KindAttachment, |
| 19 | Attachment: &attachment.AttachmentRef{ |
| 20 | Version: attachment.RefVersion, |
| 21 | Content: sessioncontent.Ref{Digest: digest, Bytes: 12, MediaType: "image/png", Name: "shot.png"}, |
| 22 | Width: 8, |
| 23 | Height: 8, |
| 24 | DisplayName: "shot.png", |
| 25 | }, |
| 26 | }}, |
| 27 | }} |
| 28 | got := historyMessages(msgs, historyReplayUserContent) |
| 29 | if len(got) != 1 || len(got[0].Attachments) != 1 { |
| 30 | t.Fatalf("history attachments = %+v", got) |
| 31 | } |
| 32 | att := got[0].Attachments[0] |
| 33 | if att.Kind != "image" || att.Digest != digest || att.Name != "shot.png" || att.MIME != "image/png" { |
| 34 | t.Fatalf("attachment = %+v", att) |
| 35 | } |
| 36 | } |
| 37 |