Медленные тесты выделены в отдельную группу и запускаются с count=10
parent
ef6e3fd62f
commit
888d9ee29f
7
Makefile
7
Makefile
|
@ -1,8 +1,11 @@
|
||||||
lint: install-lint-deps
|
lint: install-lint-deps
|
||||||
golangci-lint run ./previewer/... ./internal/...
|
golangci-lint run ./previewer/... ./internal/...
|
||||||
|
|
||||||
unit-test:
|
unit-test-fast:
|
||||||
go test -race -count 100 -timeout 30s ./internal/...
|
go test -race -count 100 -timeout 30s -short ./internal/...
|
||||||
|
|
||||||
|
unit-test-slow:
|
||||||
|
go test -race -count 10 -timeout 150s -run Slow ./internal/...
|
||||||
|
|
||||||
integration-test:
|
integration-test:
|
||||||
go test -v ./cmd/...
|
go test -v ./cmd/...
|
||||||
|
|
|
@ -138,7 +138,7 @@ func TestCacheMultithreading(t *testing.T) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for i := 0; i < 10_000; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
itm := strconv.Itoa(i)
|
itm := strconv.Itoa(i)
|
||||||
_, err := c.Set(Key(itm), []byte(itm))
|
_, err := c.Set(Key(itm), []byte(itm))
|
||||||
require.NoError(t, err, err)
|
require.NoError(t, err, err)
|
||||||
|
@ -147,8 +147,8 @@ func TestCacheMultithreading(t *testing.T) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for i := 0; i < 10_000; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
itm := strconv.Itoa(rand.Intn(10_000))
|
itm := strconv.Itoa(rand.Intn(100))
|
||||||
b, s, err := c.Get(Key(itm))
|
b, s, err := c.Get(Key(itm))
|
||||||
require.NoError(t, err, err)
|
require.NoError(t, err, err)
|
||||||
if s {
|
if s {
|
||||||
|
|
|
@ -3,11 +3,13 @@ package converter
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestResize(t *testing.T) {
|
func TestResizeSlow(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping integration test")
|
||||||
|
}
|
||||||
table := []struct {
|
table := []struct {
|
||||||
width int
|
width int
|
||||||
height 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 {
|
table := []struct {
|
||||||
topLeft image.Point
|
topLeft image.Point
|
||||||
bottomRight 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
|
originalAspect := 800.0 / 600.0
|
||||||
releasedValue := 3000
|
releasedValue := 3000
|
||||||
table := []struct {
|
table := []struct {
|
||||||
|
@ -143,6 +151,8 @@ func TestConvert(t *testing.T) {
|
||||||
|
|
||||||
func createImage(w, h int) image.Image {
|
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}})
|
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 x := 0; x < w; x++ {
|
||||||
for y := 0; y < h; y++ {
|
for y := 0; y < h; y++ {
|
||||||
switch {
|
switch {
|
||||||
|
@ -153,5 +163,6 @@ func createImage(w, h int) image.Image {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue