Медленные тесты выделены в отдельную группу и запускаются с count=10

master
Andrey Ivanov 2020-11-11 13:31:43 +03:00 committed by Andrey Ivanov
parent ef6e3fd62f
commit 888d9ee29f
3 changed files with 23 additions and 9 deletions

View File

@ -1,8 +1,11 @@
lint: install-lint-deps
golangci-lint run ./previewer/... ./internal/...
unit-test:
go test -race -count 100 -timeout 30s ./internal/...
unit-test-fast:
go test -race -count 100 -timeout 30s -short ./internal/...
unit-test-slow:
go test -race -count 10 -timeout 150s -run Slow ./internal/...
integration-test:
go test -v ./cmd/...

View File

@ -138,7 +138,7 @@ func TestCacheMultithreading(t *testing.T) {
go func() {
defer wg.Done()
for i := 0; i < 10_000; i++ {
for i := 0; i < 100; i++ {
itm := strconv.Itoa(i)
_, err := c.Set(Key(itm), []byte(itm))
require.NoError(t, err, err)
@ -147,8 +147,8 @@ func TestCacheMultithreading(t *testing.T) {
go func() {
defer wg.Done()
for i := 0; i < 10_000; i++ {
itm := strconv.Itoa(rand.Intn(10_000))
for i := 0; i < 100; i++ {
itm := strconv.Itoa(rand.Intn(100))
b, s, err := c.Get(Key(itm))
require.NoError(t, err, err)
if s {

View File

@ -3,11 +3,13 @@ package converter
import (
"github.com/stretchr/testify/require"
"image"
"image/color"
"testing"
)
func TestResize(t *testing.T) {
func TestResizeSlow(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
table := []struct {
width int
height int
@ -45,7 +47,10 @@ func TestResize(t *testing.T) {
}
}
func TestCrop(t *testing.T) {
func TestCropSlow(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
table := []struct {
topLeft image.Point
bottomRight image.Point
@ -92,7 +97,10 @@ func TestCrop(t *testing.T) {
}
}
func TestConvert(t *testing.T) {
func TestConvertSlow(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
originalAspect := 800.0 / 600.0
releasedValue := 3000
table := []struct {
@ -143,6 +151,8 @@ func TestConvert(t *testing.T) {
func createImage(w, h int) image.Image {
res := image.NewRGBA(image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: w, Y: h}})
/*
// С такой нагрузкой тест становится практически бесконечный
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
switch {
@ -153,5 +163,6 @@ func createImage(w, h int) image.Image {
}
}
}
*/
return res
}