Skip to content

Commit

Permalink
Add skip label evaluation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wsan3 committed Jun 14, 2024
1 parent aef0237 commit 0811f1f
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions pipeline/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,92 @@ func TestPipeline_Container_Execute(t *testing.T) {
},
want: true,
},
{ // pull request labeled success container with build success
container: &Container{
Name: "pull-request-labeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
If: Rules{
Branch: []string{"fix/1234"},
Event: []string{constants.EventPull + constants.ActionLabeled},
Label: []string{"enhancement", "documentation"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:labeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
{ // pull request unlabeled success container with build success
container: &Container{
Name: "pull-request-unlabeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
If: Rules{
Event: []string{constants.EventPull + constants.ActionUnlabeled},
Label: []string{"enhancement"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:unlabeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
{ // pull request labeled unless ruleset, success container with build success
container: &Container{
Name: "pull-request-labeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
Unless: Rules{
Branch: []string{"fix/1234"},
Event: []string{constants.EventPull + constants.ActionLabeled},
Label: []string{"enhancement", "documentation"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:labeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
{ // pull request unlabeled unless ruleset, success container with build success
container: &Container{
Name: "pull-request-unlabeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
Unless: Rules{
Event: []string{constants.EventPull + constants.ActionUnlabeled},
Label: []string{"enhancement"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:unlabeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
}

// run tests
Expand Down

0 comments on commit 0811f1f

Please sign in to comment.