-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
profile_image_test.go
36 lines (32 loc) · 840 Bytes
/
profile_image_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
package faker
import (
"fmt"
"strings"
"testing"
)
func TestProfileImage(t *testing.T) {
f := New()
value := f.ProfileImage().Image()
Expect(t, fmt.Sprintf("%T", value), "*os.File")
Expect(t, strings.HasSuffix(value.Name(), ".jpg"), true, value.Name())
}
func TestProfileImagePanicIfRequestFails(t *testing.T) {
f := New()
service := f.ProfileImage()
expected := fmt.Errorf("request failed")
service.HTTPClient = ErrorRaiserHTTPClient{err: expected}
defer func() {
Expect(t, recover(), expected)
}()
service.Image()
}
func TestProfileImagePanicIfTempFileCreationFails(t *testing.T) {
f := New()
service := f.ProfileImage()
expected := fmt.Errorf("temp file creation failed")
service.TempFileCreator = ErrorRaiserTempFileCreator{err: expected}
defer func() {
Expect(t, recover(), expected)
}()
service.Image()
}