diff options
author | Daniel Baumann <daniel@debian.org> | 2025-01-24 09:00:09 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2025-01-24 09:00:09 +0100 |
commit | 4bf4dabd48aa70da3699b9a023f22689645d24f4 (patch) | |
tree | ed8175444649e71c0ed0e5f1d30101786ca2473e /pkg/runner/step_factory_test.go | |
parent | Initial commit. (diff) | |
download | forgejo-act-debian.tar.xz forgejo-act-debian.zip |
Adding upstream version 1.24.0.HEADupstream/1.24.0upstreamdebian
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'pkg/runner/step_factory_test.go')
-rw-r--r-- | pkg/runner/step_factory_test.go | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/pkg/runner/step_factory_test.go b/pkg/runner/step_factory_test.go new file mode 100644 index 0000000..c981ef5 --- /dev/null +++ b/pkg/runner/step_factory_test.go @@ -0,0 +1,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) +} |