-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_test.go
57 lines (51 loc) · 1.06 KB
/
process_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
// goforever - processes management
// Copyright (c) 2013 Garrett Woodworth (https://github.com/gwoo).
// sphere-director - Ninja processes management
// Copyright (c) 2014 Ninja Blocks Inc. (https://github.com/ninjablocks).
package main
import (
"testing"
)
func TestPidfile(t *testing.T) {
c := &Config{Processes: []*Process{&Process{
Name: "test",
Pidfile: "test.pid",
}},
}
p := c.Get("test")
err := p.Pidfile.write(100)
if err != nil {
t.Errorf("Error: %s.", err)
return
}
ex := 100
r := p.Pidfile.read()
if ex != r {
t.Errorf("Expected %#v. Result %#v\n", ex, r)
}
s := p.Pidfile.delete()
if s != true {
t.Error("Failed to remove pidfile.")
return
}
}
func TestProcessStart(t *testing.T) {
c := &Config{Processes: []*Process{&Process{
Name: "bash",
Command: "/bin/bash",
Args: []string{"foo", "bar"},
Pidfile: "echo.pid",
Logfile: "debug.log",
Errfile: "error.log",
Respawn: 3,
}},
}
p := c.Get("bash")
p.start("bash")
ex := 0
r := p.x.Pid
if ex >= r {
t.Errorf("Expected %#v < %#v\n", ex, r)
}
p.stop()
}