-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect if we need to update the PipelineRun
When the Pipelinerun needs to be updated, detect and report it. We parse regexp on the "raw pipelinerun", we may have to do more in the future for other upgrades. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
- Loading branch information
Showing
3 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package pipelineascode | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestPacRun_checkNeedUpdate(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
tmpl string | ||
upgradeMessageSubstr string | ||
needupdate bool | ||
}{ | ||
{ | ||
name: "old secrets", | ||
tmpl: ` secretName: "pac-git-basic-auth-{{repo_owner}}-{{repo_name}}"`, | ||
upgradeMessageSubstr: "old basic auth secret name", | ||
needupdate: true, | ||
}, | ||
{ | ||
name: "no need", | ||
tmpl: ` secretName: "foo-bar-foo"`, | ||
needupdate: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
p := NewPacs(nil, nil, nil, nil, nil) | ||
got, needupdate := p.checkNeedUpdate(tt.tmpl) | ||
if tt.upgradeMessageSubstr != "" { | ||
assert.Assert(t, strings.Contains(got, tt.upgradeMessageSubstr)) | ||
} | ||
assert.Assert(t, needupdate == tt.needupdate) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters