mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-16 02:45:54 -07:00
refactor: crop and tests
This commit is contained in:
parent
b20ddbb8f3
commit
2e90c11e5b
3 changed files with 45 additions and 8 deletions
|
|
@ -7,13 +7,31 @@ import (
|
|||
)
|
||||
|
||||
func TestImageResize(t *testing.T) {
|
||||
data, _ := os.Open("fixtures/test.jpg")
|
||||
buf, err := ioutil.ReadAll(data)
|
||||
|
||||
image := NewImage(buf)
|
||||
|
||||
buf, err = image.Resize(300, 240)
|
||||
image := readImage()
|
||||
_, err := image.Resize(300, 240)
|
||||
if err != nil {
|
||||
t.Errorf("Cannot process the image: %#v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageCrop(t *testing.T) {
|
||||
image := readImage()
|
||||
_, err := image.Crop(300, 240)
|
||||
if err != nil {
|
||||
t.Errorf("Cannot process the image: %#v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageRotate(t *testing.T) {
|
||||
image := readImage()
|
||||
_, err := image.Rotate(D90)
|
||||
if err != nil {
|
||||
t.Errorf("Cannot process the image: %#v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func readImage() *Image {
|
||||
data, _ := os.Open("fixtures/test.jpg")
|
||||
buf, _ := ioutil.ReadAll(data)
|
||||
return NewImage(buf)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue