forked from glycerine/goq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup_test.go
61 lines (47 loc) · 1.22 KB
/
startup_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
55
56
57
58
59
60
61
package main
import (
"os"
"path/filepath"
"testing"
cv "github.com/glycerine/goconvey/convey"
)
func TestStartupInHomeDir(t *testing.T) {
cv.Convey("On 'goq serve' startup, the process should Chdir to GOQ_HOME", t, func() {
var jobserv *JobServ
var err error
var jobservPid int
remote := false
// *** universal test cfg setup
skipbye := false
// this will move us to a new tempdir
cfg := NewTestConfig()
// now move away so we can check that there is a Chdir
cv.So(cfg.tempdir, cv.ShouldNotEqual, cfg.origdir)
err = os.Chdir("..")
if err != nil {
panic(err)
}
pwd, err := os.Getwd()
if err != nil {
panic(err)
}
cv.So(pwd, cv.ShouldNotEqual, cfg.Home)
defer cfg.ByeTestConfig(&skipbye)
// *** end universal test setup
cfg.DebugMode = true // reply to badsig packets
// local only, because we use Getwd() to see what dir we are in.
jobserv, err = NewJobServ(cfg)
if err != nil {
panic(err)
}
defer CleanupServer(cfg, jobservPid, jobserv, remote, &skipbye)
defer CleanupOutdir(cfg)
pwd, err = os.Getwd()
if err != nil {
panic(err)
}
epwd, _ := filepath.EvalSymlinks(pwd)
ecfg, _ := filepath.EvalSymlinks(cfg.Home)
cv.So(epwd, cv.ShouldEqual, ecfg)
})
}