forked from canthefason/go-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch_test.go
37 lines (30 loc) · 784 Bytes
/
watch_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
package watcher
import (
"os"
"testing"
)
func TestPrepareRootDir(t *testing.T) {
w := &Watcher{}
dir, err := w.prepareRootDir()
if err != nil {
t.Errorf("Expected nil but got %s for prepareRootDir", err)
}
workingDir, _ := os.Getwd()
if dir != workingDir {
t.Errorf("Expected %s but got %s for prepareRootDir", workingDir, dir)
}
w.rootdir = "balcony"
os.Setenv("GOPATH", "")
dir, err = w.prepareRootDir()
if err != ErrPathNotSet {
t.Errorf("Expected %s but got %s for prepareRootDir", ErrPathNotSet, err)
}
os.Setenv("GOPATH", "go")
dir, err = w.prepareRootDir()
if err != nil {
t.Errorf("Expected nil but got %s for prepareRootDir", err)
}
if dir != "go/src/balcony" {
t.Errorf("Expected go/src/balcony but got %s for prepareRootDir", dir)
}
}