-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdirectories_test.go
48 lines (42 loc) · 1023 Bytes
/
directories_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 directories
import (
"fmt"
"os"
"testing"
)
//------------------------------------------------------------------------------
func TestGetHomeDirectory(t *testing.T) {
dir, err := GetHomeDirectory()
if err == nil {
fmt.Printf("Home directory: %v\n", dir)
} else {
t.Errorf("%v", err.Error())
}
}
func TestGetAppSettingsDirectory(t *testing.T) {
dir, err := GetAppSettingsDirectory()
if err == nil {
fmt.Printf("Application settings directory: %v\n", dir)
} else {
t.Errorf("%v", err.Error())
}
}
func TestGetSystemSettingsDirectory(t *testing.T) {
dir, err := GetSystemSettingsDirectory()
if err == nil {
fmt.Printf("System settings directory: %v\n", dir)
} else {
t.Errorf("%v", err.Error())
}
}
func TestAppFile(t *testing.T) {
SetAppName("dirtest")
f, err := Open(AppSettings, "sample.txt", os.O_WRONLY | os.O_CREATE, 0644)
if err == nil {
fmt.Printf("Created sample.txt file!\n")
_, _ = f.Write([]byte("test"))
_ = f.Close()
} else {
t.Errorf("%v", err.Error())
}
}