forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_test.go
46 lines (40 loc) · 950 Bytes
/
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
package job_test
import (
"testing"
"github.com/runabol/tork/job"
"github.com/runabol/tork/task"
"github.com/stretchr/testify/assert"
)
func TestClone(t *testing.T) {
j1 := &job.Job{
Context: job.Context{
Inputs: map[string]string{
"INPUT1": "VAL1",
},
},
Tasks: []*task.Task{
{
Env: map[string]string{
"VAR1": "VAL1",
},
},
},
Execution: []*task.Task{
{
Env: map[string]string{
"EVAR1": "EVAL1",
},
},
},
}
j2 := j1.Clone()
assert.Equal(t, j1.Context.Inputs, j2.Context.Inputs)
assert.Equal(t, j1.Tasks[0].Env, j2.Tasks[0].Env)
assert.Equal(t, j1.Execution[0].Env, j2.Execution[0].Env)
j2.Context.Inputs["INPUT2"] = "VAL2"
j2.Tasks[0].Env["VAR2"] = "VAL2"
j2.Execution[0].Env["EVAR2"] = "VAL2"
assert.NotEqual(t, j1.Context.Inputs, j2.Context.Inputs)
assert.NotEqual(t, j1.Tasks[0].Env, j2.Tasks[0].Env)
assert.NotEqual(t, j1.Execution[0].Env, j2.Execution[0].Env)
}