mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
It will be imported by Forgejo. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/777): <!--number 777 --><!--line 0 --><!--description Y2hvcmU6IHRvIGFsbG93IHRoZSBydW5uZXIgdG8gYmUgaW1wb3J0ZWQsIHY5IG5lZWRzIHRvIGJlIGluIHRoZSBnbyBtb2R1bGU=-->chore: to allow the runner to be imported, v9 needs to be in the go module<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/777 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
81 lines
1.3 KiB
Go
81 lines
1.3 KiB
Go
package runner
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.forgejo.org/forgejo/runner/v9/act/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)
|
|
}
|