diff --git a/api4/file_test.go b/api4/file_test.go index 70e32820c5..d955dca1ef 100644 --- a/api4/file_test.go +++ b/api4/file_test.go @@ -5,6 +5,7 @@ package api4 import ( "bytes" + "encoding/hex" "fmt" "io" "io/ioutil" @@ -221,13 +222,13 @@ func TestUploadFiles(t *testing.T) { // Upload a bunch of files, mixed images and non-images { title: "Happy", - names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md", "test.tiff"}, + names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md", "test_compressed_tiff.tiff"}, expectedCreatorId: th.BasicUser.Id, }, // Upload a bunch of files, with clientIds { title: "Happy client_ids", - names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md", "test.tiff"}, + names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md", "test_compressed_tiff.tiff"}, clientIds: []string{"1", "2", "3", "4", "5"}, expectedCreatorId: th.BasicUser.Id, }, @@ -356,9 +357,20 @@ func TestUploadFiles(t *testing.T) { // TIFF preview test { title: "Happy image thumbnail/preview 9", - names: []string{"test.tiff"}, - expectedImageThumbnailNames: []string{"test_expected_thumb.tiff"}, - expectedImagePreviewNames: []string{"test_expected_preview.tiff"}, + names: []string{"test_compressed_tiff.tiff"}, + expectedImageThumbnailNames: []string{"test_expected_tiff_thumb.jpeg"}, + expectedImagePreviewNames: []string{"test_expected_tiff_preview.jpeg"}, + expectImage: true, + expectedImageWidths: []int{701}, + expectedImageHeights: []int{701}, + expectedImageHasPreview: []bool{true}, + expectedCreatorId: th.BasicUser.Id, + }, + { + title: "Happy image thumbnail/preview 10", + names: []string{"test_raw_tiff.tiff"}, + expectedImageThumbnailNames: []string{"test_expected_tiff_thumb.jpeg"}, + expectedImagePreviewNames: []string{"test_expected_tiff_preview.jpeg"}, expectImage: true, expectedImageWidths: []int{701}, expectedImageHeights: []int{701}, @@ -609,10 +621,16 @@ func TestUploadFiles(t *testing.T) { require.Nil(t, err) if !bytes.Equal(data, expected) { tf, err := ioutil.TempFile("", fmt.Sprintf("test_%v_*_%s", i, name)) + defer tf.Close() require.Nil(t, err) - _, _ = io.Copy(tf, bytes.NewReader(data)) - tf.Close() - t.Errorf("Actual data mismatched %s, written to %q", name, tf.Name()) + _, err = io.Copy(tf, bytes.NewReader(data)) + require.Nil(t, err) + if strings.Contains(name, "test_expected_tiff") { + // TODO: remove this once MM-22056 is fixed. + t.Errorf("Actual data mismatched %s, written to %q - expected %d bytes, got %d. Previewer Image: \n\n%s\n", name, tf.Name(), len(expected), len(data), hex.Dump(data)) + } else { + t.Errorf("Actual data mismatched %s, written to %q - expected %d bytes, got %d.", name, tf.Name(), len(expected), len(data)) + } } } if len(tc.expectedPayloadNames) == 0 { diff --git a/app/post_metadata_test.go b/app/post_metadata_test.go index f65ab845ff..24bda46ac9 100644 --- a/app/post_metadata_test.go +++ b/app/post_metadata_test.go @@ -2181,7 +2181,7 @@ func TestParseImages(t *testing.T) { }, }, "tiff": { - FileName: "test.tiff", + FileName: "test_compressed_tiff.tiff", Expected: (*model.PostImage)(nil), }, "not an image": { diff --git a/tests/test.tiff b/tests/test_compressed_tiff.tiff similarity index 100% rename from tests/test.tiff rename to tests/test_compressed_tiff.tiff diff --git a/tests/test_expected_preview.tiff b/tests/test_expected_tiff_preview.jpeg similarity index 100% rename from tests/test_expected_preview.tiff rename to tests/test_expected_tiff_preview.jpeg diff --git a/tests/test_expected_thumb.tiff b/tests/test_expected_tiff_thumb.jpeg similarity index 100% rename from tests/test_expected_thumb.tiff rename to tests/test_expected_tiff_thumb.jpeg diff --git a/tests/test_raw_tiff.tiff b/tests/test_raw_tiff.tiff new file mode 100644 index 0000000000..5d5ec68f67 Binary files /dev/null and b/tests/test_raw_tiff.tiff differ