From be90c9afe1330d3fc13c39b9cd7c92381cf3de80 Mon Sep 17 00:00:00 2001 From: Javier Palomo Date: Tue, 13 Apr 2021 12:39:39 +0200 Subject: [PATCH] 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/ --- internal/match/match_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/match/match_test.go b/internal/match/match_test.go index 0c477bf..0c4d888 100644 --- a/internal/match/match_test.go +++ b/internal/match/match_test.go @@ -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",