39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
from contextlib import redirect_stderr
|
|
import io
|
|
import unittest
|
|
|
|
from ptlinux.cli import build_parser
|
|
|
|
|
|
class LauncherUpdateCliTests(unittest.TestCase):
|
|
def test_bare_rollback_uses_retained_previous_release(self) -> None:
|
|
arguments = build_parser().parse_args(["launcher-update", "--rollback"])
|
|
self.assertEqual(arguments.rollback, "")
|
|
|
|
def test_explicit_rollback_accepts_version_and_history_override(self) -> None:
|
|
arguments = build_parser().parse_args(
|
|
[
|
|
"launcher-update",
|
|
"--rollback",
|
|
"1.8.0",
|
|
"--history-url",
|
|
"https://updates.example.test/history.json",
|
|
]
|
|
)
|
|
self.assertEqual(arguments.rollback, "1.8.0")
|
|
self.assertEqual(
|
|
arguments.history_url,
|
|
"https://updates.example.test/history.json",
|
|
)
|
|
|
|
def test_rollback_remains_exclusive_with_check_and_verify(self) -> None:
|
|
parser = build_parser()
|
|
with redirect_stderr(io.StringIO()), self.assertRaises(SystemExit):
|
|
parser.parse_args(["launcher-update", "--rollback", "--check"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|