Skip to content

Commit 4702fb7

Browse files
committed
cli tests
1 parent b9b3851 commit 4702fb7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/github/test_release_page.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from git import Repo
1010
from moto import mock_aws
1111

12+
import gardenlinux
1213
import gardenlinux.github.__main__ as gh
1314
from gardenlinux.apt.debsource import DebsrcFile
1415
from gardenlinux.features import CName
@@ -421,3 +422,43 @@ def test_script_parse_args_upload_command_required_args(monkeypatch, capfd):
421422

422423
assert "the following arguments are required: --release_id, --file_path" in captured.err, \
423424
"Expected help message on missing arguments for 'upload' command"
425+
426+
427+
def test_script_create_dry_run(monkeypatch, capfd):
428+
429+
monkeypatch.setattr(sys, "argv", ["gh", "create", "--owner", "gardenlinux", "--repo",
430+
"gardenlinux", "--tag", GARDENLINUX_RELEASE, "--commit", GARDENLINUX_COMMIT, "--dry-run"])
431+
monkeypatch.setattr("gardenlinux.github.__main__.create_github_release_notes",
432+
lambda tag, commit: f"{tag} {commit}")
433+
434+
gh.main()
435+
captured = capfd.readouterr()
436+
437+
assert captured.out == f"{GARDENLINUX_RELEASE} {GARDENLINUX_COMMIT}\n", \
438+
"Expected dry-run create to return generated release notes text"
439+
440+
441+
def test_script_create(monkeypatch, caplog):
442+
monkeypatch.setattr(sys, "argv", ["gh", "create", "--owner", "gardenlinux", "--repo",
443+
"gardenlinux", "--tag", GARDENLINUX_RELEASE, "--commit", GARDENLINUX_COMMIT])
444+
monkeypatch.setattr("gardenlinux.github.__main__.create_github_release_notes",
445+
lambda tag, commit: f"{tag} {commit}")
446+
monkeypatch.setattr("gardenlinux.github.__main__.create_github_release",
447+
lambda a1, a2, a3, a4, a5: GARDENLINUX_RELEASE)
448+
449+
gh.main()
450+
451+
assert any(f"Release created with ID: {GARDENLINUX_RELEASE}" in record.message for record in caplog.records), \
452+
"Expected a release creation confirmation log entry"
453+
454+
455+
def test_script_upload_dry_run(monkeypatch, capfd):
456+
monkeypatch.setattr(sys, "argv", ["gh", "upload", "--owner", "gardenlinux", "--repo",
457+
"gardenlinux", "--release_id", GARDENLINUX_RELEASE, "--file_path", "foo", "--dry-run"])
458+
monkeypatch.setattr("gardenlinux.github.__main__.upload_to_github_release_page",
459+
lambda a1, a2, a3, a4, dry_run: print(f"dry-run: {dry_run}"))
460+
461+
gh.main()
462+
captured = capfd.readouterr()
463+
464+
assert captured.out == "dry-run: True\n"

0 commit comments

Comments
 (0)