summaryrefslogtreecommitdiffstats
path: root/model/job_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-07-26 17:39:51 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-07-26 17:39:51 -0400
commitf5375254f90053bd9b688d36f758aca309ec3735 (patch)
tree45ec76d772286305269c5006d67be267e63bbb41 /model/job_test.go
parent528890dba01d6835754c78bf7695621c828b6838 (diff)
downloadchat-f5375254f90053bd9b688d36f758aca309ec3735.tar.gz
chat-f5375254f90053bd9b688d36f758aca309ec3735.tar.bz2
chat-f5375254f90053bd9b688d36f758aca309ec3735.zip
Adding migration support to LDAP from other account types (#3655)
Diffstat (limited to 'model/job_test.go')
-rw-r--r--model/job_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/model/job_test.go b/model/job_test.go
index 2a307de1e..8908fed58 100644
--- a/model/job_test.go
+++ b/model/job_test.go
@@ -126,3 +126,63 @@ func TestGetAllTasks(t *testing.T) {
}
}
}
+
+func TestExecuteTask(t *testing.T) {
+ TASK_NAME := "Test Task"
+ TASK_TIME := time.Second * 5
+
+ testValue := 0
+ testFunc := func() {
+ testValue += 1
+ }
+
+ task := CreateTask(TASK_NAME, testFunc, TASK_TIME)
+ if testValue != 0 {
+ t.Fatal("Unexpected execuition of task")
+ }
+
+ task.Execute()
+
+ if testValue != 1 {
+ t.Fatal("Task did not execute")
+ }
+
+ time.Sleep(TASK_TIME + time.Second)
+
+ if testValue != 2 {
+ t.Fatal("Task re-executed")
+ }
+}
+
+func TestExecuteTaskRecurring(t *testing.T) {
+ TASK_NAME := "Test Recurring Task"
+ TASK_TIME := time.Second * 5
+
+ testValue := 0
+ testFunc := func() {
+ testValue += 1
+ }
+
+ task := CreateRecurringTask(TASK_NAME, testFunc, TASK_TIME)
+ if testValue != 0 {
+ t.Fatal("Unexpected execuition of task")
+ }
+
+ time.Sleep(time.Second * 3)
+
+ task.Execute()
+ if testValue != 1 {
+ t.Fatal("Task did not execute")
+ }
+
+ time.Sleep(time.Second * 3)
+ if testValue != 1 {
+ t.Fatal("Task should not have executed before 5 seconds")
+ }
+
+ time.Sleep(time.Second * 3)
+
+ if testValue != 2 {
+ t.Fatal("Task did not re-execute after forced execution")
+ }
+}