woodpecker/server/pipeline/items_test.go
6543 5a7b689e30
Switch to go vanity urls (#2706)
Co-authored-by: Anbraten <anton@ju60.de>
2023-11-07 08:04:33 +01:00

52 lines
1,003 B
Go

package pipeline
import (
"testing"
sharedPipeline "go.woodpecker-ci.org/woodpecker/pipeline"
"go.woodpecker-ci.org/woodpecker/pipeline/backend/types"
"go.woodpecker-ci.org/woodpecker/server/model"
)
func TestSetPipelineStepsOnPipeline(t *testing.T) {
t.Parallel()
pipeline := &model.Pipeline{
ID: 1,
Event: model.EventPush,
}
pipelineItems := []*sharedPipeline.Item{{
Workflow: &model.Workflow{
PID: 1,
},
Config: &types.Config{
Stages: []*types.Stage{
{
Steps: []*types.Step{
{
Name: "clone",
},
},
},
{
Steps: []*types.Step{
{
Name: "step",
},
},
},
},
},
}}
pipeline = setPipelineStepsOnPipeline(pipeline, pipelineItems)
if len(pipeline.Workflows) != 1 {
t.Fatal("Should generate three in total")
}
if pipeline.Workflows[0].PipelineID != 1 {
t.Fatal("Should set workflow's pipeline ID")
}
if pipeline.Workflows[0].Children[0].PPID != 1 {
t.Fatal("Should set step PPID")
}
}