mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-14 06:51:52 +02:00
refactor: move act under internal
The runner is an application, not a library. `act/model` and `act/exprparser` were the last packages anything outside this repository consumed and they now live in actionslib, so nothing needs the rest of `act` to be importable, and keeping it importable invites the coupling that was just removed. Import paths only, the files are unchanged. Assisted-by: Codet:GPT-5.1-Codex
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
// 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)
|
||||
}
|
||||
Reference in New Issue
Block a user