diff --git a/pkg/filesystem/image_test.go b/pkg/filesystem/image_test.go index 0c4d0261..9678df92 100644 --- a/pkg/filesystem/image_test.go +++ b/pkg/filesystem/image_test.go @@ -38,3 +38,12 @@ func TestFileSystem_GetThumb(t *testing.T) { asserts.EqualValues(50, res.MaxAge) } } + +func TestFileSystem_ThumbWorker(t *testing.T) { + asserts := assert.New(t) + + asserts.NotPanics(func() { + getThumbWorker().addWorker() + getThumbWorker().releaseWorker() + }) +} diff --git a/pkg/thumb/image_test.go b/pkg/thumb/image_test.go index 7fe65a18..210a39a4 100644 --- a/pkg/thumb/image_test.go +++ b/pkg/thumb/image_test.go @@ -86,6 +86,30 @@ func TestThumb_GetThumb(t *testing.T) { }) } +func TestThumb_Thumbnail(t *testing.T) { + asserts := assert.New(t) + { + img := image.NewRGBA(image.Rect(0, 0, 500, 200)) + thumb := Thumbnail(100, 100, img) + asserts.Equal(thumb.Bounds(), image.Rect(0, 0, 100, 40)) + } + { + img := image.NewRGBA(image.Rect(0, 0, 200, 200)) + thumb := Thumbnail(100, 100, img) + asserts.Equal(thumb.Bounds(), image.Rect(0, 0, 100, 100)) + } + { + img := image.NewRGBA(image.Rect(0, 0, 500, 500)) + thumb := Thumbnail(100, 100, img) + asserts.Equal(thumb.Bounds(), image.Rect(0, 0, 100, 100)) + } + { + img := image.NewRGBA(image.Rect(0, 0, 200, 500)) + thumb := Thumbnail(100, 100, img) + asserts.Equal(thumb.Bounds(), image.Rect(0, 0, 40, 100)) + } +} + func TestThumb_Save(t *testing.T) { asserts := assert.New(t) file := CreateTestImage()