mediaimage_test.go 1.66 KiB
Newer Older
package mediamdl

import (
	"path/filepath"
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_compressImage(t *testing.T) {
	inputPath := "../testingdata/testData/mediamdl/image/sample.bmp"
	inputPath, _ = filepath.Abs(inputPath)
	outputPath := "../testingdata/testData/mediamdl/image/sample-compress-image.jpg"
	outputPath, _ = filepath.Abs(outputPath)
	err := compressImage(inputPath, outputPath)
	// fmt.Println("err: ", err)
	assert.NoError(t, err, "This will not thrown an error.")
}

func Test1_compressImage(t *testing.T) {
	inputPath := "../testingdata/testData/mediamdl/image/path with spaces/sample.bmp"
	inputPath, _ = filepath.Abs(inputPath)
	outputPath := "../testingdata/testData/mediamdl/image/path with spaces/sample-compress-image.jpg"
	outputPath, _ = filepath.Abs(outputPath)
	err := compressImage(inputPath, outputPath)
	// fmt.Println("err: ", err)
	assert.NoError(t, err, "This will not thrown an error.")
}

func Test_resizeImage(t *testing.T) {
	inputPath := "../testingdata/testData/mediamdl/image/sample.bmp"
	outputPath := "../testingdata/testData/mediamdl/image/sample-resized-image.bmp"
	err := resizeImage(inputPath, outputPath, "100")
	assert.NoError(t, err, "This will not throw error")
}

func Test_resizeImageWithoutAspectRatio(t *testing.T) {
	inputPath := "../testingdata/testData/mediamdl/image/sample.bmp"
	outputPath := "../testingdata/testData/mediamdl/image/sample-resize-wo-aspect-image.bmp"
	err := resizeImageWithoutAspectRatio(inputPath, outputPath, "100", "100")
	assert.NoError(t, err, "This will not throw error")
}

func Test_smartCropImage(t *testing.T) {
	err := smartCropImage()
	assert.Error(t, err, "This will not throw error")