-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhimage_test.go
46 lines (37 loc) · 1000 Bytes
/
himage_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package himage
import (
"errors"
"image/png"
"path/filepath"
"testing"
)
func TestNewHimageWithPath(t *testing.T) {
hImage := NewHimageWithPath(filepath.Join("test-files", "850x566.png"))
if hImage.Error != nil {
t.Error(hImage.Error)
}
if hImage.Detail.Mime != "image/png" {
t.Error(errors.New("detail mime is not valid"))
}
if hImage.Detail.Width != 850 {
t.Error(errors.New("detail width is not valid"))
}
if hImage.Detail.Height != 566 {
t.Error(errors.New("detail height is not valid"))
}
if hImage.Detail.Size == 0 {
t.Error(errors.New("detail size is not valid"))
}
if hImage.qPNG != png.DefaultCompression {
t.Error(errors.New("png compression is not valid"))
}
if len(hImage.quality) == 0 {
t.Error(errors.New("quality specs is not valid"))
}
}
func TestNewHimageWithPathNotExistsFile(t *testing.T) {
hImage := NewHimageWithPath(filepath.Join("test-files", "notfoung.png"))
if hImage.Error == nil {
t.Error(errors.New("invalid file open"))
}
}