Skip to content

Commit

Permalink
Improve RepoList test coverage (#90)
Browse files Browse the repository at this point in the history
* Improve RepoList test coverage

To ensure we don't see bug #87 again.

Also added a few other misc. test improvements.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
sm-gravid-day and pre-commit-ci[bot] authored Dec 18, 2022
1 parent 270a0eb commit d336d13
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/data/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ artifactory-cleanup:
policies:
- name: Remove all files from repo-name-here older then 7 days
rules:
- rule: Repo
name: "repo-name-here"
- rule: RepoList
repos:
- "repo-name-here"
- rule: DeleteOlderThan
days: 7

Expand Down
5 changes: 5 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def test_help(capsys):
],
exit=False,
)
stdout, stderr = capsys.readouterr()
assert "Usage:" in stdout
assert not stderr
assert code == 0


Expand All @@ -29,6 +32,7 @@ def test_dry_mode(capsys, shared_datadir, requests_mock):
stdout, stderr = capsys.readouterr()
assert code == 0, stdout
assert "Verbose MODE" in stdout
assert "Destroy MODE" not in stdout
assert (
"DEBUG - we would delete 'repo-name-here/path/to/file/filename1.json'" in stdout
)
Expand All @@ -54,6 +58,7 @@ def test_destroy(capsys, shared_datadir, requests_mock):
stdout, stderr = capsys.readouterr()
assert code == 0, stdout
assert "Destroy MODE" in stdout
assert "Verbose MODE" not in stdout

assert (
requests_mock.call_count == 6
Expand Down
8 changes: 8 additions & 0 deletions tests/test_rules_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ def test_RepoList():
]
}
]
session = "session"
today = "today"
rule.init(session, today, "arg1", "arg2", "arg3", abc=123)
assert rule.session is None
assert rule.today is None
for repo in rule.repos:
assert repo.session == session
assert repo.today == today

0 comments on commit d336d13

Please sign in to comment.