mirror of
https://codeberg.org/crowci/crow.git
synced 2025-08-09 07:42:52 +03:00
Rework status constraint logic for successes (#1515)
Since "success" and "failure" are the only two possible values, and "success" is considered to be included by default, the existing code can also be simplified a little. This has the side effect of ignoring the "exclude" part of the constraint completely. I put it in the tests just to make sure the workaround in https://github.com/woodpecker-ci/woodpecker/issues/1181#issuecomment-1347253585 continues to work as expected, but couldn't think of any legitimate use cases for it. Fixes #1181
This commit is contained in:
@@ -381,6 +381,24 @@ func TestConstraintMap(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraintStatusSuccess(t *testing.T) {
|
||||
testdata := []struct {
|
||||
conf string
|
||||
want bool
|
||||
}{
|
||||
{conf: "", want: true},
|
||||
{conf: "{status: [failure]}", want: false},
|
||||
{conf: "{status: [success]}", want: true},
|
||||
{conf: "{status: [failure, success]}", want: true},
|
||||
{conf: "{status: {exclude: [success], include: [failure]}}", want: false},
|
||||
{conf: "{status: {exclude: [failure], include: [success]}}", want: true},
|
||||
}
|
||||
for _, test := range testdata {
|
||||
c := parseConstraints(t, test.conf)
|
||||
assert.Equal(t, test.want, c.IncludesStatusSuccess(), "when: '%s'", test.conf)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraints(t *testing.T) {
|
||||
testdata := []struct {
|
||||
desc string
|
||||
|
Reference in New Issue
Block a user