@@ -23,6 +23,9 @@ func TestFetchAndStoreAttachment(t *testing.T) {
23
23
"http://mock.com/media/hello2" : {
24
24
httpx .NewMockResponse (200 , map [string ]string {"Content-Type" : "image/jpeg" }, testJPG ),
25
25
},
26
+ "http://mock.com/media/hello3" : {
27
+ httpx .NewMockResponse (200 , map [string ]string {"Content-Type" : "application/octet-stream" }, testJPG ),
28
+ },
26
29
"http://mock.com/media/hello.mp3" : {
27
30
httpx .NewMockResponse (502 , nil , []byte (`My gateways!` )),
28
31
},
@@ -82,6 +85,12 @@ func TestFetchAndStoreAttachment(t *testing.T) {
82
85
assert .NoError (t , err )
83
86
assert .Equal (t , & courier.Attachment {ContentType : "unavailable" , URL : "http://mock.com/media/hello.pdf" }, att )
84
87
88
+ att , err = courier .FetchAndStoreAttachment (ctx , mb , mockChannel , "http://mock.com/media/hello3" , clog )
89
+ assert .NoError (t , err )
90
+ assert .Equal (t , "image/jpeg" , att .ContentType )
91
+ assert .Equal (t , "https://backend.com/attachments/338ff339-5663-49ed-8ef6-384876655d1b.jpg" , att .URL )
92
+ assert .Equal (t , 17301 , att .Size )
93
+
85
94
// an actual error on our part should be returned as an error
86
95
mb .SetStorageError (errors .New ("boom" ))
87
96
0 commit comments