Skip to content

Commit

Permalink
Add TestPipelineName to procBuilder_test.go (#461) (#455)
Browse files Browse the repository at this point in the history
Backport #461 

Add test for a bug where pipelines that use `depends_on` were not built in multi-pipeline builds. The problem is that pipelines names keep a leading `'/'` when the pipeline path does not have a trailing `'/'`.
  • Loading branch information
ctbur authored Oct 19, 2021
1 parent 53efebd commit 5861995
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions server/procBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,41 @@ depends_on:
}
}

func TestPipelineName(t *testing.T) {
t.Parallel()

b := procBuilder{
Repo: &model.Repo{Config: ".woodpecker"},
Curr: &model.Build{},
Last: &model.Build{},
Netrc: &model.Netrc{},
Secs: []*model.Secret{},
Regs: []*model.Registry{},
Link: "",
Yamls: []*remote.FileMeta{
&remote.FileMeta{Name: ".woodpecker/lint.yml", Data: []byte(`
pipeline:
build:
image: scratch
`)},
&remote.FileMeta{Name: ".woodpecker/.test.yml", Data: []byte(`
pipeline:
build:
image: scratch
`)},
},
}

buildItems, err := b.Build()
if err != nil {
t.Fatal(err)
}
pipelineNames := []string{buildItems[0].Proc.Name, buildItems[1].Proc.Name}
if !containsItemWithName("lint", buildItems) || !containsItemWithName("test", buildItems) {
t.Fatalf("Pipeline name should be 'lint' and 'test' but are '%v'", pipelineNames)
}
}

func TestRunsOn(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 5861995

Please sign in to comment.