| 1 | package provider |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/attachment" |
| 7 | "reasonix/internal/sessioncontent" |
| 8 | ) |
| 9 | |
| 10 | func TestMessageRejectsCombinedImageFields(t *testing.T) { |
| 11 | msg := Message{ |
| 12 | Images: []string{"data:image/png;base64,AA=="}, |
| 13 | ImageInputs: []attachment.ImageInput{{ |
| 14 | Kind: attachment.KindAttachment, |
| 15 | Attachment: &attachment.AttachmentRef{ |
| 16 | Version: attachment.RefVersion, |
| 17 | Content: sessioncontent.Ref{Digest: "aa", Bytes: 1, MediaType: "image/png"}, |
| 18 | Width: 1, Height: 1, |
| 19 | }, |
| 20 | }}, |
| 21 | } |
| 22 | if err := msg.ValidateImageFields(); err == nil { |
| 23 | t.Fatal("expected combined image fields to be rejected") |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestLegacyImagesRemainValid(t *testing.T) { |
| 28 | msg := Message{Images: []string{"https://cdn.example.com/a.png"}} |
| 29 | if err := msg.ValidateImageFields(); err != nil { |
| 30 | t.Fatal(err) |
| 31 | } |
| 32 | if !msg.HasImagePayload() { |
| 33 | t.Fatal("legacy images should count as a payload") |
| 34 | } |
| 35 | } |
| 36 |