Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
[RP-1048] Make sure version & branch are overridden in inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
knaveofdiamonds committed Apr 25, 2018
1 parent 159e735 commit 7fb9c45
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
8 changes: 8 additions & 0 deletions cli/pipeline/pipeline_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ func (p *PipelineDefinitionStep) OverrideTag(tag string) {
func (p *PipelineDefinitionStep) OverrideVersion(version string) {
if version != "" {
p.Version = version

for i := range p.Inputs {
p.Inputs[i].Version = version
}
}
}

func (p *PipelineDefinitionStep) OverrideBranch(branch string) {
if branch != "" {
p.Branch = branch

for i := range p.Inputs {
p.Inputs[i].Branch = branch
}
}
}
20 changes: 14 additions & 6 deletions cli/pipeline/pipeline_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ func TestOverrideVersion(t *testing.T) {
t.Errorf("Version is %s", pipeline.Steps[0].Version)
}

pipeline.Steps[0].OverrideVersion("foo")
pipeline.Steps[1].OverrideVersion("foo")

if pipeline.Steps[0].Version != "foo" {
t.Errorf("Version is %s", pipeline.Steps[0].Version)
if pipeline.Steps[1].Version != "foo" {
t.Errorf("Version is %s", pipeline.Steps[1].Version)
}

if pipeline.Steps[1].Inputs[0].Version != "foo" {
t.Errorf("Dependent input Version is %s", pipeline.Steps[1].Inputs[0].Version)
}
}

Expand All @@ -74,9 +78,13 @@ func TestOverrideBranch(t *testing.T) {
t.Errorf("Branch is %s", pipeline.Steps[0].Branch)
}

pipeline.Steps[0].OverrideBranch("foo")
pipeline.Steps[1].OverrideBranch("foo")

if pipeline.Steps[0].Branch != "foo" {
t.Errorf("Branch is %s", pipeline.Steps[0].Branch)
if pipeline.Steps[1].Branch != "foo" {
t.Errorf("Branch is %s", pipeline.Steps[1].Branch)
}

if pipeline.Steps[1].Inputs[0].Branch != "foo" {
t.Errorf("Dependent input Branch is %s", pipeline.Steps[1].Inputs[0].Branch)
}
}

0 comments on commit 7fb9c45

Please sign in to comment.