forked from timjwright/godoit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_test.go
47 lines (39 loc) · 1.41 KB
/
job_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPathMatching(t *testing.T) {
job := ParseJobFile("a_path", "0 30 * * * * job name .godoit")
assert.NotNil(t, job, "Failed to parse job")
assert.Equal(t, "0 30 * * * *", job.Spec)
assert.Equal(t, "job name", job.Name)
assert.Equal(t, "a_path/0 30 * * * * job name .godoit", job.Filepath)
}
func TestPathMatchingWithRepalce(t *testing.T) {
job := ParseJobFile("a_path", "0 0%5 x x x x job name.godoit")
assert.NotNil(t, job, "Failed to parse job")
assert.Equal(t, "0 0/5 * * * *", job.Spec)
assert.Equal(t, "job name", job.Name)
assert.Equal(t, "a_path/0 0%5 x x x x job name.godoit", job.Filepath)
}
func TestPathMatching2(t *testing.T) {
job := ParseJobFile("a_path", "* * * * * * TestScanRemoveJob.godoit")
assert.NotNil(t, job, "Failed to parse job")
}
func TestPathAll(t *testing.T) {
job := ParseJobFile("a_path", "* * * * * * job name.godoit")
assert.NotNil(t, job, "Failed to parse job")
}
func TestCommentedOutJobShouldBeNil(t *testing.T) {
job := ParseJobFile("a_path", "--0 30 * * * * job name.godoit")
assert.Nil(t, job, "Should be nil")
}
func TestIncompleteTaskShouldBeNil(t *testing.T) {
job := ParseJobFile("a_path", "0 30 * * *.godoit")
assert.Nil(t, job, "Should be nil")
}
func TestWithoutNameShouldBeNil(t *testing.T) {
job := ParseJobFile("a_path", "0 30 * * * *.godoit")
assert.Nil(t, job, "Should be nil")
}