-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
75 lines (70 loc) · 1.82 KB
/
main_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"bytes"
"testing"
)
const testFullResult = `├───project
│ ├───file.txt (19b)
│ └───gopher.png (70372b)
├───static
│ ├───a_lorem
│ │ ├───dolor.txt (empty)
│ │ ├───gopher.png (70372b)
│ │ └───ipsum
│ │ └───gopher.png (70372b)
│ ├───css
│ │ └───body.css (28b)
│ ├───empty.txt (empty)
│ ├───html
│ │ └───index.html (57b)
│ ├───js
│ │ └───site.js (10b)
│ └───z_lorem
│ ├───dolor.txt (empty)
│ ├───gopher.png (70372b)
│ └───ipsum
│ └───gopher.png (70372b)
├───zline
│ ├───empty.txt (empty)
│ └───lorem
│ ├───dolor.txt (empty)
│ ├───gopher.png (70372b)
│ └───ipsum
│ └───gopher.png (70372b)
└───zzfile.txt (empty)
`
func TestTreeFull(t *testing.T) {
out := new(bytes.Buffer)
err := dirTree(out, "testdata", true)
if err != nil {
t.Errorf("test for OK Failed - error")
}
result := out.String()
if result != testFullResult {
t.Errorf("test for OK Failed - results not match\nGot:\n%v\nExpected:\n%v", result, testFullResult)
}
}
const testDirResult = `├───project
├───static
│ ├───a_lorem
│ │ └───ipsum
│ ├───css
│ ├───html
│ ├───js
│ └───z_lorem
│ └───ipsum
└───zline
└───lorem
└───ipsum
`
func TestTreeDir(t *testing.T) {
out := new(bytes.Buffer)
err := dirTree(out, "testdata", false)
if err != nil {
t.Errorf("test for OK Failed - error")
}
result := out.String()
if result != testDirResult {
t.Errorf("test for OK Failed - results not match\nGot:\n%v\nExpected:\n%v", result, testDirResult)
}
}