Skip to content

Commit

Permalink
Review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Sep 22, 2023
1 parent 585edac commit 89ca28a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tests/media_filename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func TestMediaFilenames(t *testing.T) {

mxcUri := alice.UploadContent(t, data.MatrixPng, filename, "image/png")

name, isAttachment := downloadForFilename(t, alice, mxcUri, "")
name, _ := downloadForFilename(t, alice, mxcUri, "")

// filename is not required, but if it's an attachment then check it matches
if isAttachment && name != filename {
if name != filename {
t.Fatalf("Incorrect filename '%s', expected '%s'", name, filename)
}
})
Expand All @@ -57,12 +57,12 @@ func TestMediaFilenames(t *testing.T) {
t.Run("Can download specifying a different ASCII file name", func(t *testing.T) {
t.Parallel()

mxcUri := alice.UploadContent(t, data.MatrixPng, "test.png", "image/png")
mxcUri := alice.UploadContent(t, data.MatrixPng, asciiFileName, "image/png")

const altName = "file.png"
filename, isAttachment := downloadForFilename(t, alice, mxcUri, altName)
filename, _ := downloadForFilename(t, alice, mxcUri, altName)

if isAttachment && filename != altName {
if filename != altName {
t.Fatalf("filename did not match, expected '%s', got '%s'", altName, filename)
}
})
Expand All @@ -86,9 +86,9 @@ func TestMediaFilenames(t *testing.T) {

const diffUnicodeFilename = "\u2615" // coffee emoji

filename, isAttachment := downloadForFilename(t, alice, mxcUri, diffUnicodeFilename)
filename, _ := downloadForFilename(t, alice, mxcUri, diffUnicodeFilename)

if isAttachment && filename != diffUnicodeFilename {
if filename != diffUnicodeFilename {
t.Fatalf("filename did not match, expected '%s', got '%s'", diffUnicodeFilename, filename)
}
})
Expand All @@ -99,9 +99,9 @@ func TestMediaFilenames(t *testing.T) {

mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")

filename, isAttachment := downloadForFilename(t, alice, mxcUri, "")
filename, _ := downloadForFilename(t, alice, mxcUri, "")

if isAttachment && filename != unicodeFileName {
if filename != unicodeFileName {
t.Fatalf("filename did not match, expected '%s', got '%s'", unicodeFileName, filename)
}
})
Expand All @@ -112,9 +112,9 @@ func TestMediaFilenames(t *testing.T) {

mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")

filename, isAttachment := downloadForFilename(t, bob, mxcUri, "")
filename, _ := downloadForFilename(t, bob, mxcUri, "")

if isAttachment && filename != unicodeFileName {
if filename != unicodeFileName {
t.Fatalf("filename did not match, expected '%s', got '%s'", unicodeFileName, filename)
}
})
Expand Down Expand Up @@ -166,7 +166,6 @@ func downloadForFilename(t *testing.T, c *client.CSAPI, mxcUri string, diffName
return filename, true
} else {
t.Fatalf("Content Disposition did not have filename")
return "", true
}
}
if mediaType != "inline" {
Expand Down

0 comments on commit 89ca28a

Please sign in to comment.