Conv emoji to testify (#12900)
* 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>
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
187e4ac765
Коммит
c0186cef1a
@@ -11,14 +11,15 @@ import (
|
|||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateTestGif(t *testing.T, width int, height int) []byte {
|
func CreateTestGif(t *testing.T, width int, height int) []byte {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
if err := gif.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil); err != nil {
|
err := gif.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil)
|
||||||
t.Fatalf("failed to create gif: %v", err.Error())
|
require.NoErrorf(t, err, "failed to create gif: %v", err)
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.Bytes()
|
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.Image[i] = image.NewPaletted(image.Rect(0, 0, width, height), color.Palette{color.Black})
|
||||||
img.Delay[i] = 0
|
img.Delay[i] = 0
|
||||||
}
|
}
|
||||||
if err := gif.EncodeAll(&buffer, &img); err != nil {
|
err := gif.EncodeAll(&buffer, &img)
|
||||||
t.Fatalf("failed to create animated gif: %v", err.Error())
|
require.NoErrorf(t, err, "failed to create animated gif: %v", err)
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.Bytes()
|
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 {
|
func CreateTestJpeg(t *testing.T, width int, height int) []byte {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
if err := jpeg.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil); err != nil {
|
err := jpeg.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)), nil)
|
||||||
t.Fatalf("failed to create jpeg: %v", err.Error())
|
require.NoErrorf(t, err, "failed to create jpeg: %v", err)
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.Bytes()
|
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 {
|
func CreateTestPng(t *testing.T, width int, height int) []byte {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
if err := png.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height))); err != nil {
|
err := png.Encode(&buffer, image.NewRGBA(image.Rect(0, 0, width, height)))
|
||||||
t.Fatalf("failed to create png: %v", err.Error())
|
require.NoErrorf(t, err, "failed to create png: %v", err)
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.Bytes()
|
return buffer.Bytes()
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user