-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathos_test.go
48 lines (39 loc) · 1.06 KB
/
os_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
package coldfire_test
import (
"os"
"testing"
"github.com/google/uuid"
coldfire "github.com/redcode-labs/Coldfire"
)
func TestIsRoot(t *testing.T) {
r := coldfire.IsRoot()
t.Logf("%v", r)
}
func TestExists(t *testing.T) {
fname := uuid.NewString()
f, err := os.Create(fname)
if err != nil {
t.Errorf("failed to create test file: %s", err.Error())
}
f.Close()
if b := coldfire.Exists(fname); !b {
t.Errorf("coldfire.Exists: check failed: got %v, wanted %v", b, true)
}
if err := os.Remove(fname); err != nil {
t.Errorf("failed to remove test file: %s", err.Error())
}
}
func TestFilePermissions(t *testing.T) {
fname := uuid.NewString()
f, err := os.Create(fname)
if err != nil {
t.Errorf("failed to create test file: %s", err.Error())
}
f.Close()
if r, w := coldfire.FilePermissions(fname); !r || !w {
t.Errorf("coldfire.Exists: check failed: got %v %v, wanted %v %v", r, w, true, true)
}
if err := os.Remove(fname); err != nil {
t.Errorf("failed to remove test file: %s", err.Error())
}
}