* convert fatal to requrie

Signed-off-by: hanif <abuhanifa@pathao.com>

* finish convert

Signed-off-by: hanif <abuhanifa@pathao.com>

* change require.Errof to require.Failf

Signed-off-by: hanif <abuhanifa@pathao.com>

* simplify conditions

Signed-off-by: hanif <abuhanifa@pathao.com>
Этот коммит содержится в:
Abu Hanifa
2019-10-25 23:49:33 +06:00
коммит произвёл Harrison Healey
родитель 187e4ac765
Коммит c0186cef1a

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

@@ -11,14 +11,15 @@ import (
"image/jpeg"
"image/png"
"testing"
"github.com/stretchr/testify/require"
)
func CreateTestGif(t *testing.T, width int, height int) []byte {
var buffer bytes.Buffer
if err := gif.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil); err != nil {
t.Fatalf("failed to create gif: %v", err.Error())
}
err := gif.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil)
require.NoErrorf(t, err, "failed to create gif: %v", err)
return buffer.Bytes()
}
@@ -34,9 +35,8 @@ func CreateTestAnimatedGif(t *testing.T, width int, height int, frames int) []by
img.Image[i] = image.NewPaletted(image.Rect(0, 0, width, height), color.Palette{color.Black})
img.Delay[i] = 0
}
if err := gif.EncodeAll(&buffer, &img); err != nil {
t.Fatalf("failed to create animated gif: %v", err.Error())
}
err := gif.EncodeAll(&buffer, &img)
require.NoErrorf(t, err, "failed to create animated gif: %v", err)
return buffer.Bytes()
}
@@ -44,9 +44,8 @@ func CreateTestAnimatedGif(t *testing.T, width int, height int, frames int) []by
func CreateTestJpeg(t *testing.T, width int, height int) []byte {
var buffer bytes.Buffer
if err := jpeg.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil); err != nil {
t.Fatalf("failed to create jpeg: %v", err.Error())
}
err := jpeg.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil)
require.NoErrorf(t, err, "failed to create jpeg: %v", err)
return buffer.Bytes()
}
@@ -54,9 +53,8 @@ func CreateTestJpeg(t *testing.T, width int, height int) []byte {
func CreateTestPng(t *testing.T, width int, height int) []byte {
var buffer bytes.Buffer
if err := png.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height))); err != nil {
t.Fatalf("failed to create png: %v", err.Error())
}
err := png.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)))
require.NoErrorf(t, err, "failed to create png: %v", err)
return buffer.Bytes()
}