MM-22056: Fix flaky test TestUploadFiles (#14234)

Automatic Merge
Этот коммит содержится в:
Agniva De Sarker
2020-04-07 19:39:04 +05:30
коммит произвёл GitHub
родитель 22a00104bd
Коммит 4210ae60ab
5 изменённых файлов: 19 добавлений и 50 удалений

Просмотреть файл

@@ -26,6 +26,7 @@ import (
"github.com/disintegration/imaging"
"github.com/rwcarlsen/goexif/exif"
_ "golang.org/x/image/bmp"
_ "golang.org/x/image/tiff"
"github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model"
@@ -796,29 +797,29 @@ func (t *UploadFileTask) postprocessImage() {
return
}
const jpegQuality = 90
writeJPEG := func(img image.Image, path string) {
r, w := io.Pipe()
go func() {
_, aerr := t.writeFile(r, path)
if aerr != nil {
mlog.Error("Unable to upload", mlog.String("path", path), mlog.Err(aerr))
return
err := jpeg.Encode(w, img, &jpeg.Options{Quality: jpegQuality})
if err != nil {
mlog.Error("Unable to encode image as jpeg", mlog.String("path", path), mlog.Err(err))
w.CloseWithError(err)
} else {
w.Close()
}
}()
err := jpeg.Encode(w, img, &jpeg.Options{Quality: 90})
if err != nil {
mlog.Error("Unable to encode image as jpeg", mlog.String("path", path), mlog.Err(err))
w.CloseWithError(err)
} else {
w.Close()
_, aerr := t.writeFile(r, path)
if aerr != nil {
mlog.Error("Unable to upload", mlog.String("path", path), mlog.Err(aerr))
return
}
}
w := decoded.Bounds().Dx()
h := decoded.Bounds().Dy()
wg := &sync.WaitGroup{}
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()

Просмотреть файл

@@ -2181,7 +2181,7 @@ func TestParseImages(t *testing.T) {
},
},
"tiff": {
FileName: "test_compressed_tiff.tiff",
FileName: "test.tiff",
Expected: (*model.PostImage)(nil),
},
"not an image": {