mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
22dfd2ef62
- refactor pipeline parsing - do not parse the pipeline multiple times to perform filter checks, do this once and perform checks on the result directly - code deduplication - refactor forge token refreshing - move refreshing to a helper func to reduce code --------- Co-authored-by: Anbraten <anton@ju60.de>
52 lines
1,015 B
Go
52 lines
1,015 B
Go
package pipeline
|
|
|
|
import (
|
|
"testing"
|
|
|
|
sharedPipeline "github.com/woodpecker-ci/woodpecker/pipeline"
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
|
"github.com/woodpecker-ci/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")
|
|
}
|
|
}
|