-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pim_test.go
70 lines (61 loc) · 1.5 KB
/
pim_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
62
63
64
65
66
67
68
69
package main
import (
lib "github.com/TimoKats/pim/commands/lib"
pim "github.com/TimoKats/pim/commands"
"testing"
"time"
)
var database lib.Database
var process = lib.Process{
Runs:[]lib.Run{
lib.Run{
Name: "linux-command",
Schedule: "@start+5",
Command: "echo hello world",
},
lib.Run{
Name: "sleepy-command",
Schedule: "@hourly",
Command: "sleep 50",
Duration: 5,
},
lib.Run{
Name: "sleepy-command",
Schedule: "@start+10",
Command: "echo bye world",
},
},
}
func TestLs(t *testing.T) {
cmdErr := pim.ListCommand(process, &database)
if cmdErr != nil {
t.Errorf("Error in ls command: %v", cmdErr)
}
}
func TestNonTimedRun(t *testing.T) {
command := []string{"one", "sleep", "linux-command"}
cmdErr := pim.RunCommand(command, process, &database)
if cmdErr != nil {
t.Errorf("Error in run command: %v", cmdErr)
}
}
func TestTimedRun(t *testing.T) {
command := []string{"one", "sleep", "sleepy-command"}
cmdErr := pim.RunCommand(command, process, &database)
if cmdErr != nil {
t.Errorf("Error in run command: %v", cmdErr)
}
}
func TestLog(t *testing.T) {
command := []string{"one", "two"}
cmdErr := pim.LogCommand(command, &database)
if cmdErr != nil {
t.Errorf("Error in log command: %v", cmdErr)
}
}
func TestStart(t *testing.T) {
go pim.StartCommand(process, &database) //nolint:errcheck
time.Sleep(10 * time.Second)
lib.Info.Println("pim start works!")
lib.PIMTERMINATE = true
}