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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package runner
import (
"testing"
"github.com/nektos/act/pkg/model"
"github.com/stretchr/testify/assert"
)
func TestStepFactoryNewStep(t *testing.T) {
table := []struct {
name string
model *model.Step
check func(s step) bool
}{
{
name: "StepRemoteAction",
model: &model.Step{
Uses: "remote/action@v1",
},
check: func(s step) bool {
_, ok := s.(*stepActionRemote)
return ok
},
},
{
name: "StepLocalAction",
model: &model.Step{
Uses: "./action@v1",
},
check: func(s step) bool {
_, ok := s.(*stepActionLocal)
return ok
},
},
{
name: "StepDocker",
model: &model.Step{
Uses: "docker://image:tag",
},
check: func(s step) bool {
_, ok := s.(*stepDocker)
return ok
},
},
{
name: "StepRun",
model: &model.Step{
Run: "cmd",
},
check: func(s step) bool {
_, ok := s.(*stepRun)
return ok
},
},
}
for _, tt := range table {
t.Run(tt.name, func(t *testing.T) {
sf := &stepFactoryImpl{}
step, err := sf.newStep(tt.model, &RunContext{})
assert.True(t, tt.check((step)))
assert.Nil(t, err)
})
}
}
func TestStepFactoryInvalidStep(t *testing.T) {
model := &model.Step{
Uses: "remote/action@v1",
Run: "cmd",
}
sf := &stepFactoryImpl{}
_, err := sf.newStep(model, &RunContext{})
assert.Error(t, err)
}
|