forked from argoproj/argo-cd
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filter applications by source repo URL (argoproj#5602) (argopro…
…j#5603) * feat: filter applications by source repo URL (argoproj#5602) Signed-off-by: Samuel Suter <[email protected]> * Unit test for FilterByRepo
- Loading branch information
Showing
8 changed files
with
277 additions
and
146 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -336,6 +336,40 @@ func TestFilterByProjects(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestFilterByRepo(t *testing.T) { | ||
apps := []argoappv1.Application{ | ||
{ | ||
Spec: argoappv1.ApplicationSpec{ | ||
Source: argoappv1.ApplicationSource{ | ||
RepoURL: "[email protected]:owner/repo.git", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Spec: argoappv1.ApplicationSpec{ | ||
Source: argoappv1.ApplicationSource{ | ||
RepoURL: "[email protected]:owner/otherrepo.git", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
t.Run("Empty filter", func(t *testing.T) { | ||
res := FilterByRepo(apps, "") | ||
assert.Len(t, res, 2) | ||
}) | ||
|
||
t.Run("Match", func(t *testing.T) { | ||
res := FilterByRepo(apps, "[email protected]:owner/repo.git") | ||
assert.Len(t, res, 1) | ||
}) | ||
|
||
t.Run("No match", func(t *testing.T) { | ||
res := FilterByRepo(apps, "[email protected]:owner/willnotmatch.git") | ||
assert.Len(t, res, 0) | ||
}) | ||
} | ||
|
||
func TestValidatePermissions(t *testing.T) { | ||
t.Run("Empty Repo URL result in condition", func(t *testing.T) { | ||
spec := argoappv1.ApplicationSpec{ | ||
|