forked from distribworks/dkron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows to run commands using shell or not using it.
- Loading branch information
Victor Castell
committed
May 17, 2016
1 parent
da1d988
commit f7ad64b
Showing
3 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,37 @@ package dkron | |
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSchedule(t *testing.T) { | ||
sched := NewScheduler() | ||
|
||
if sched.Started == true { | ||
t.Fatal("The scheduler should be stopped.") | ||
} | ||
assert.NotEqual(t, true, sched.Started) | ||
|
||
testJob1 := &Job{ | ||
Name: "cron_job", Schedule: "@every 2s", Command: "echo 'test1'", Owner: "John Dough", OwnerEmail: "[email protected]", | ||
Name: "cron_job", | ||
Schedule: "@every 2s", | ||
Command: "echo 'test1'", | ||
Owner: "John Dough", | ||
OwnerEmail: "[email protected]", | ||
Shell: true, | ||
} | ||
sched.Start([]*Job{testJob1}) | ||
|
||
if sched.Started != true { | ||
t.Fatal("The scheduler should be started.") | ||
} | ||
assert.Equal(t, true, sched.Started) | ||
|
||
testJob2 := &Job{ | ||
Name: "cron_job", Schedule: "@every 5s", Command: "echo 'test2'", Owner: "John Dough", OwnerEmail: "[email protected]", | ||
Name: "cron_job", | ||
Schedule: "@every 5s", | ||
Command: "echo 'test2'", | ||
Owner: "John Dough", | ||
OwnerEmail: "[email protected]", | ||
Shell: true, | ||
} | ||
sched.Restart([]*Job{testJob2}) | ||
|
||
if sched.Started != true { | ||
t.Fatal("The scheduler should be started.") | ||
} | ||
|
||
if len(sched.Cron.Entries()) > 1 { | ||
t.Fatal("The scheduler has more jobs than expected.") | ||
} | ||
assert.Equal(t, true, sched.Started) | ||
assert.Len(t, sched.Cron.Entries(), 1, "The scheduler has more jobs than expected.") | ||
} |