-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat_test.go
63 lines (47 loc) · 1.69 KB
/
stat_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
package pathutil
import (
"os"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExists(t *testing.T) {
path, _ := New("stat_test.go")
assert.Exactly(t, true, path.Exists(), "file exists")
path, _ = New("/sdlkfjsflsjfsl")
assert.Exactly(t, false, path.Exists(), "wired root dir don't exists")
path, _ = New(os.TempDir())
assert.Exactly(t, true, path.Exists(), "home dir exists")
}
func TestIsDir(t *testing.T) {
path, _ := New(os.TempDir())
assert.Exactly(t, true, path.IsDir(), "temp dir is dir")
path, _ = New("stat_test.go")
assert.Exactly(t, false, path.IsDir(), "this test file isn't dir")
path, _ = New("/safjasfjalfja")
assert.Exactly(t, false, path.IsDir(), "unexists somethings isn't dir")
}
func TestIsFile(t *testing.T) {
path, _ := New(os.TempDir())
assert.Exactly(t, false, path.IsFile(), "temp dir is dir - no file")
path, _ = New("stat_test.go")
assert.Exactly(t, true, path.IsFile(), "this test file is file")
path, _ = New("/safjasfjalfja")
assert.Exactly(t, false, path.IsFile(), "unexists something isn't file")
if runtime.GOOS != "windows" {
path, _ = New("/dev/zero")
assert.Exactly(t, true, path.IsFile(), "/dev/zero is file")
}
//symlink test
}
func TestIsRegularFile(t *testing.T) {
path, _ := New(os.TempDir())
assert.Exactly(t, false, path.IsRegularFile(), "temp dir is dir - no file")
path, _ = New("stat_test.go")
assert.Exactly(t, true, path.IsRegularFile(), "this test file is file")
path, _ = New("/safjasfjalfja")
assert.Exactly(t, false, path.IsRegularFile(), "unexists something isn't file")
path, _ = New("/dev/zero")
assert.Exactly(t, false, path.IsRegularFile(), "/dev/zero isn't regular file file")
//symlink test
}