Add TestPipelineName to procBuilder_test.go (#461)

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 `'/'`.
This commit is contained in:
Cyrill Burgener 2021-10-19 09:35:10 +02:00 committed by GitHub
parent bbbb53b9bc
commit fd8e0b248b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -174,6 +174,41 @@ runs_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 TestBranchFilter(t *testing.T) {
t.Parallel()