-
Notifications
You must be signed in to change notification settings - Fork 31
/
listformatter_test.go
56 lines (45 loc) · 1.16 KB
/
listformatter_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
47
48
49
50
51
52
53
54
55
56
package graval
import (
. "github.com/smartystreets/goconvey/convey"
"os"
"testing"
"time"
)
type TestFileInfo struct{}
func (t *TestFileInfo) Name() string {
return "file1.txt"
}
func (t *TestFileInfo) Size() int64 {
return 99
}
func (t *TestFileInfo) Mode() os.FileMode {
return os.ModeSymlink
}
func (t *TestFileInfo) IsDir() bool {
return false
}
func (t *TestFileInfo) ModTime() time.Time {
return time.Unix(1, 0)
}
func (t *TestFileInfo) Sys() interface{} {
return nil
}
var files []os.FileInfo = []os.FileInfo{
&TestFileInfo{}, &TestFileInfo{},
}
func TestShortFormat(t *testing.T) {
formatter := newListFormatter(files)
Convey("The Short listing format", t, func() {
Convey("Will display correctly", func() {
So(formatter.Short(), ShouldEqual, "file1.txt\r\nfile1.txt\r\n\r\n")
})
})
}
func TestDetailedFormat(t *testing.T) {
formatter := newListFormatter(files)
Convey("The Detailed listing format", t, func() {
Convey("Will display correctly", func() {
So(formatter.Detailed(), ShouldEqual, "L--------- 1 owner group 99 Jan 01 00:00 file1.txt\r\nL--------- 1 owner group 99 Jan 01 00:00 file1.txt\r\n\r\n")
})
})
}