Test that inverse matches work for DRONE_LIMIT_REPOS

Added some additional unit tests to verify that `DRONE_LIMIT_REPOS`
works for inverse matches. Given that the matching is based on
path/filepath, inverse matches are supported.

Related docs:
https://docs.drone.io/runner/docker/configuration/reference/drone-limit-repos/
This commit is contained in:
Javier Palomo
2021-04-13 12:39:39 +02:00
parent d926749258
commit be90c9afe1

View File

@@ -30,7 +30,7 @@ func TestFunc(t *testing.T) {
match: true,
matcher: Func([]string{"spaceghost/*", "octocat/*"}, []string{"push"}, true),
},
// repoisitory matching
// repository matching
{
repo: "octocat/hello-world",
event: "pull_request",
@@ -38,6 +38,14 @@ func TestFunc(t *testing.T) {
match: true,
matcher: Func([]string{"spaceghost/*", "octocat/*"}, []string{}, false),
},
// repository matching, skipping an org
{
repo: "octocat/hello-world",
event: "pull_request",
trusted: false,
match: true,
matcher: Func([]string{"!spaceghost/*", "octocat/*"}, []string{}, false),
},
// event matching
{
repo: "octocat/hello-world",
@@ -67,6 +75,22 @@ func TestFunc(t *testing.T) {
match: false,
matcher: Func([]string{"octocat/*"}, []string{}, false),
},
// repository matching, skip all repos in the org
{
repo: "spaceghost/hello-world",
event: "pull_request",
trusted: false,
match: false,
matcher: Func([]string{"!spaceghost/*"}, []string{}, false),
},
// repository matching, skip a concrete repo
{
repo: "spaceghost/hello-world",
event: "pull_request",
trusted: false,
match: false,
matcher: Func([]string{"!spaceghost/hello-world"}, []string{}, false),
},
// event matching
{
repo: "octocat/hello-world",