-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfileinfo_test.go
54 lines (43 loc) · 1.42 KB
/
fileinfo_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
/*
* Rufs - Remote Union File System
*
* Copyright 2017 Matthias Ladkau. All rights reserved.
*
* This Source Code Form is subject to the terms of the MIT
* License, If a copy of the MIT License was not distributed with this
* file, You can obtain one at https://opensource.org/licenses/MIT.
*/
package rufs
import (
"io/ioutil"
"os"
"testing"
"time"
)
func TestFileInfo(t *testing.T) {
oldUnitTestModes := unitTestModes
unitTestModes = false
defer func() {
unitTestModes = oldUnitTestModes
}()
fi := &FileInfo{"test", 500, os.FileMode(0764), time.Time{}, "123", false, ""}
if fi.String() != "test 123 [500] -rwxrw-r-- (0001-01-01 00:00:00 +0000 UTC) - <nil>" {
t.Error("Unexpected result:", fi)
return
}
fi = &FileInfo{"test", 500, os.FileMode(0764), time.Time{}, "", false, ""}
if fi.String() != "test [500] -rwxrw-r-- (0001-01-01 00:00:00 +0000 UTC) - <nil>" {
t.Error("Unexpected result:", fi)
return
}
ioutil.WriteFile("foo.txt", []byte("bar"), 0660)
defer os.Remove("foo.txt")
fi = &FileInfo{"foo.txt", 500, os.ModeSymlink, time.Time{}, "", false, ""}
fi = WrapFileInfo("./", fi).(*FileInfo)
if fi.String() != "foo.txt [3] -rw-rw---- (0001-01-01 00:00:00 +0000 UTC) - <nil>" &&
fi.String() != "foo.txt [3] -rw-r----- (0001-01-01 00:00:00 +0000 UTC) - <nil>" &&
fi.String() != "foo.txt [3] -rw-rw-rw- (0001-01-01 00:00:00 +0000 UTC) - <nil>" {
t.Error("Unexpected result:", fi)
return
}
}