|
1 | 1 | package csapi_tests
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "bytes" |
4 | 5 | "net/http"
|
5 | 6 | "strings"
|
6 | 7 | "testing"
|
@@ -36,11 +37,23 @@ func TestAsyncUpload(t *testing.T) {
|
36 | 37 | }
|
37 | 38 | })
|
38 | 39 |
|
| 40 | + wantContentType := "image/png" |
| 41 | + |
39 | 42 | 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) |
41 | 44 | })
|
42 | 45 |
|
43 | 46 | 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 | + } |
45 | 58 | })
|
46 | 59 | }
|
0 commit comments