Skip to content

Commit cd122f0

Browse files
committed
fixup! async uploads: add initial set of tests
Signed-off-by: Sumner Evans <[email protected]>
1 parent b742049 commit cd122f0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/csapi/media_async_uploads_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package csapi_tests
22

33
import (
4+
"bytes"
45
"net/http"
56
"strings"
67
"testing"
@@ -36,11 +37,23 @@ func TestAsyncUpload(t *testing.T) {
3637
}
3738
})
3839

40+
wantContentType := "image/png"
41+
3942
t.Run("Upload media", func(t *testing.T) {
40-
alice.UploadMediaAsync(t, origin, mediaID, data.MatrixPng, "test.png", "image/png")
43+
alice.UploadMediaAsync(t, origin, mediaID, data.MatrixPng, "test.png", wantContentType)
4144
})
4245

4346
t.Run("Cannot upload to a media ID that has already been uploaded to", func(t *testing.T) {
44-
alice.UploadMediaAsync(t, origin, mediaID, data.MatrixPng, "test.png", "image/png")
47+
alice.UploadMediaAsync(t, origin, mediaID, data.MatrixPng, "test.png", wantContentType)
48+
})
49+
50+
t.Run("Download media", func(t *testing.T) {
51+
content, contentType := alice.DownloadContent(t, mxcURI)
52+
if !bytes.Equal(data.MatrixPng, content) {
53+
t.Fatalf("uploaded and downloaded content doesn't match: want %v\ngot\n%v", data.MatrixPng, content)
54+
}
55+
if contentType != wantContentType {
56+
t.Fatalf("expected contentType to be %s, got %s", wantContentType, contentType)
57+
}
4558
})
4659
}

0 commit comments

Comments
 (0)