From fd8e0b248b1338dfc4c17456c6b4cfe68ce3f5a1 Mon Sep 17 00:00:00 2001 From: Cyrill Burgener <41328971+ctbur@users.noreply.github.com> Date: Tue, 19 Oct 2021 09:35:10 +0200 Subject: [PATCH] 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 `'/'`. --- server/shared/procBuilder_test.go | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/server/shared/procBuilder_test.go b/server/shared/procBuilder_test.go index a48a6e3d6..eccea2514 100644 --- a/server/shared/procBuilder_test.go +++ b/server/shared/procBuilder_test.go @@ -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()