@@ -614,8 +614,8 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
614614 // Find the image or text message from our test
615615 for i := range fetchResp .ReceivedSMSs {
616616 msg := & fetchResp .ReceivedSMSs [i ]
617- if ( msg .ContentType == "application/x-acro-filetransfer+json" || msg . SMSText == "Test text message before image" || msg . SMSText == "Test image message" ) && len ( msg . Attachments ) > 0 {
618- t .Logf ("Attempt %d: Found image message with %d attachments " , attempts + 1 , len ( msg .Attachments ) )
617+ if msg .ContentType == "application/x-acro-filetransfer+json" {
618+ t .Logf ("Attempt %d: Found image message with content type %s " , attempts + 1 , msg .ContentType )
619619 imageMsg = msg
620620 break
621621 }
@@ -639,23 +639,29 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
639639 }
640640
641641 // Verify attachment structure
642- if len (imageMsg .Attachments ) == 0 {
643- t .Fatalf ("image message has no attachments" )
642+ var ft models.FileTransfer
643+ err = json .Unmarshal ([]byte (imageMsg .SMSText ), & ft )
644+ if err != nil {
645+ t .Fatalf ("failed to unmarshal SMSText as FileTransfer: %v. SMSText: %s" , err , imageMsg .SMSText )
646+ }
647+
648+ if len (ft .Attachments ) == 0 {
649+ t .Fatalf ("image message has no attachments in FileTransfer" )
644650 }
645651
646- attachment := imageMsg .Attachments [0 ]
647- t .Logf ("Attachment type: %s, url: %s, size: %d" , attachment .Type , attachment .URL , attachment .Size )
652+ attachment := ft .Attachments [0 ]
653+ t .Logf ("Attachment content- type: %s, url: %s, size: %d" , attachment .ContentType , attachment .ContentURL , attachment .ContentSize )
648654
649- if attachment .Type == "" {
650- t .Errorf ("attachment type is empty" )
655+ if attachment .ContentType == "" {
656+ t .Errorf ("attachment content- type is empty" )
651657 }
652658
653- if attachment .URL == "" {
654- t .Errorf ("attachment url is empty" )
659+ if attachment .ContentURL == "" {
660+ t .Errorf ("attachment content- url is empty" )
655661 }
656662
657- if attachment .Size == 0 {
658- t .Errorf ("attachment size is 0" )
663+ if attachment .ContentSize == 0 {
664+ t .Errorf ("attachment content- size is 0" )
659665 }
660666
661667 // Verify preview exists
@@ -666,13 +672,13 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
666672 // Step 3: Download the image and verify it matches
667673 t .Run ("VerifyImagePreview" , func (t * testing.T ) {
668674 // Verify that the attachment has a preview with the correct structure
669- if imageMsg .Attachments [0 ].Preview == nil {
675+ if ft .Attachments [0 ].Preview == nil {
670676 t .Fatalf ("attachment has no preview" )
671677 }
672678
673- preview := imageMsg .Attachments [0 ].Preview
674- if preview .Type != "image/jpeg" {
675- t .Errorf ("preview type is %s, expected image/jpeg" , preview .Type )
679+ preview := ft .Attachments [0 ].Preview
680+ if preview .ContentType != "image/jpeg" {
681+ t .Errorf ("preview content- type is %s, expected image/jpeg" , preview .ContentType )
676682 }
677683
678684 if preview .Content == "" {
@@ -690,11 +696,11 @@ func TestIntegration_SendAndFetchImageMessages(t *testing.T) {
690696 }
691697
692698 // Verify the attachment structure
693- t .Logf ("Attachment structure verified: Type =%s, URL =%s, Size =%d, HasPreview=%v" ,
694- imageMsg .Attachments [0 ].Type ,
695- imageMsg .Attachments [0 ].URL ,
696- imageMsg .Attachments [0 ].Size ,
697- imageMsg .Attachments [0 ].Preview != nil )
699+ t .Logf ("Attachment structure verified: ContentType =%s, ContentURL =%s, ContentSize =%d, HasPreview=%v" ,
700+ ft .Attachments [0 ].ContentType ,
701+ ft .Attachments [0 ].ContentURL ,
702+ ft .Attachments [0 ].ContentSize ,
703+ ft .Attachments [0 ].Preview != nil )
698704 })
699705 })
700706}
0 commit comments