-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathtask_test.go
62 lines (57 loc) · 1.26 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package tork_test
import (
"testing"
"github.com/runabol/tork"
"github.com/stretchr/testify/assert"
)
func TestCloneTask(t *testing.T) {
t1 := &tork.Task{
Env: map[string]string{
"VAR1": "VAL1",
},
Limits: &tork.TaskLimits{
CPUs: "1",
},
Parallel: &tork.ParallelTask{
Tasks: []*tork.Task{
{
Env: map[string]string{
"PVAR1": "PVAL1",
},
},
},
},
}
t2 := t1.Clone()
assert.Equal(t, t1.Env, t2.Env)
assert.Equal(t, t1.Limits.CPUs, t2.Limits.CPUs)
assert.Equal(t, t1.Parallel.Tasks[0].Env, t2.Parallel.Tasks[0].Env)
t2.Env["VAR2"] = "VAL2"
t2.Limits.CPUs = "2"
t2.Parallel.Tasks[0].Env["PVAR2"] = "PVAL2"
assert.NotEqual(t, t1.Env, t2.Env)
assert.NotEqual(t, t1.Limits.CPUs, t2.Limits.CPUs)
assert.NotEqual(t, t1.Parallel.Tasks[0].Env, t2.Parallel.Tasks[0].Env)
}
func TestIsActive(t *testing.T) {
t1 := &tork.Task{
State: tork.TaskStateCancelled,
}
assert.False(t, t1.IsActive())
t2 := &tork.Task{
State: tork.TaskStateCreated,
}
assert.True(t, t2.IsActive())
t3 := &tork.Task{
State: tork.TaskStatePending,
}
assert.True(t, t3.IsActive())
t4 := &tork.Task{
State: tork.TaskStateRunning,
}
assert.True(t, t4.IsActive())
t5 := &tork.Task{
State: tork.TaskStateCompleted,
}
assert.False(t, t5.IsActive())
}