-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutility_test.go
More file actions
50 lines (41 loc) · 1.25 KB
/
Copy pathutility_test.go
File metadata and controls
50 lines (41 loc) · 1.25 KB
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
47
48
49
50
package main
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestRandStr(t *testing.T) {
Convey("Given the lenght of the string to be generated", t, func() {
Convey("generates a random string", func() {
str := randStr(10)
So(len(str), ShouldEqual, 10)
})
})
}
func TestIsImage(t *testing.T) {
Convey("Given a name file", t, func() {
Convey("return true if the extension is an image extension", func() {
So(isImage("image.jpg"), ShouldBeTrue)
So(isImage("image.png"), ShouldBeTrue)
})
Convey("return true if the extension is an image extension, also for uppercase", func() {
So(isImage("image.PNG"), ShouldBeTrue)
})
Convey("return false if the extension name is wrong written", func() {
So(isImage("imagejpg"), ShouldBeFalse)
})
Convey("return false if the extension is not an image extension", func() {
So(isImage("text.doc"), ShouldBeFalse)
})
})
}
func TestIsJpeg(t *testing.T) {
Convey("Given a name file", t, func() {
Convey("return true if the extension is a jpg extension", func() {
So(isJpeg("image.jpg"), ShouldBeTrue)
})
Convey("return false if the extension is not a jpg", func() {
So(isJpeg("text.doc"), ShouldBeFalse)
So(isJpeg("image.png"), ShouldBeFalse)
})
})
}