-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtask_test.go
43 lines (34 loc) · 893 Bytes
/
task_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
package bokchoy_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/thoas/bokchoy"
)
func TestTask_Serialize(t *testing.T) {
is := assert.New(t)
task := bokchoy.NewTask("task.message", "hello")
is.NotZero(task)
serializer := bokchoy.JSONSerializer{}
results, err := task.Serialize(serializer)
is.Nil(err)
is.NotZero(results)
is.True(task.IsStatusWaiting())
is.Equal(task.Name, "task.message")
is.NotZero(task.Payload)
is.NotZero(task.PublishedAt)
task2, err := bokchoy.TaskFromPayload(results, serializer)
is.Nil(err)
is.NotZero(task2)
}
func TestTask_Finished(t *testing.T) {
is := assert.New(t)
task := bokchoy.NewTask("task.message", "hello")
is.False(task.Finished())
task.MarkAsSucceeded()
is.True(task.Finished())
task.MarkAsFailed(nil)
task.MaxRetries = 0
is.True(task.Finished())
task.MaxRetries = 3
is.False(task.Finished())
}