Files
Runner/act/runner/step_factory_test.go
T
Renovate Bot e30c2fed62 chore: update deps, adapt lint, use json v2 (#1185)
- Raised go to 1.27
- Adopted json v2
- Sync lint config from gitea
- Fixed all issues

Co-authored-by: silverwind <me@silverwind.io>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1185
Reviewed-by: bircni <bircni@icloud.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
2026-08-24 19:53:17 +00:00

86 lines
1.5 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// Copyright 2022 The nektos/act Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package runner
import (
"testing"
"gitea.dev/actionslib/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.NoError(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)
}