forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_test.go
50 lines (44 loc) · 1.02 KB
/
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
47
48
49
50
package tork_test
import (
"testing"
"github.com/runabol/tork"
"github.com/stretchr/testify/assert"
)
func TestClone(t *testing.T) {
j1 := &tork.Job{
Context: tork.JobContext{
Inputs: map[string]string{
"INPUT1": "VAL1",
},
Job: map[string]string{
"id": "some-id",
"name": "my job",
},
},
Tasks: []*tork.Task{
{
Env: map[string]string{
"VAR1": "VAL1",
},
},
},
Execution: []*tork.Task{
{
Env: map[string]string{
"EVAR1": "EVAL1",
},
},
},
}
j2 := j1.Clone()
assert.Equal(t, j1.Context.Inputs, j2.Context.Inputs)
assert.Equal(t, j1.Context.Job, j2.Context.Job)
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)
}