diff --git a/Makefile b/Makefile index a475754..b4a462b 100644 --- a/Makefile +++ b/Makefile @@ -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/... diff --git a/internal/cache/cache_test.go b/internal/cache/cache_test.go index 388422a..9b361e3 100644 --- a/internal/cache/cache_test.go +++ b/internal/cache/cache_test.go @@ -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 { diff --git a/internal/converter/converter_test.go b/internal/converter/converter_test.go index dbb2e2a..40ab80c 100644 --- a/internal/converter/converter_test.go +++ b/internal/converter/converter_test.go @@ -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 }