10 func TestLoadGlobal(t *testing.T) { |
10 func TestLoadGlobal(t *testing.T) { |
11 baseDir = "." |
11 baseDir = "." |
12 |
12 |
13 _, err := loadGlobal(filepath.Join("test", "non.toml")) |
13 _, err := loadGlobal(filepath.Join("test", "non.toml")) |
14 assert.Error(t, err, "does not exist") |
14 assert.Error(t, err, "does not exist") |
|
15 |
|
16 _, err = loadGlobal(filepath.Join("test", "garbage.token")) |
|
17 assert.Error(t, err, "just garbage") |
15 |
18 |
16 // git does now allow you to checkin 000 files :( |
19 // git does now allow you to checkin 000 files :( |
17 err = os.Chmod(filepath.Join("test", "perms.toml"), 000) |
20 err = os.Chmod(filepath.Join("test", "perms.toml"), 000) |
18 _, err = loadGlobal(filepath.Join("test", "perms.toml")) |
21 _, err = loadGlobal(filepath.Join("test", "perms.toml")) |
19 assert.Error(t, err, "unreadable") |
22 assert.Error(t, err, "unreadable") |
41 } |
44 } |
42 |
45 |
43 func TestGetInstanceList(t *testing.T) { |
46 func TestGetInstanceList(t *testing.T) { |
44 baseDir = "test" |
47 baseDir = "test" |
45 |
48 |
46 real := []string{"test/foo.token"} |
49 real := []string{"test/foo.token", "test/garbage.token"} |
47 list := GetInstanceList() |
50 list := GetInstanceList() |
48 assert.Equal(t, real, list, "equal") |
51 assert.Equal(t, real, list, "equal") |
49 |
52 |
50 baseDir = "/tmp" |
53 baseDir = "/tmp" |
51 real = nil |
54 real = nil |
52 list = GetInstanceList() |
55 list = GetInstanceList() |
53 assert.Equal(t, real, list, "equal") |
56 assert.Equal(t, real, list, "equal") |
|
57 |
|
58 baseDir = "/nonexistent" |
|
59 real = nil |
|
60 list = GetInstanceList() |
|
61 assert.Equal(t, real, list, "equal") |
54 } |
62 } |