feat(install): pipelines update re-runs the recorded install from the source checkout; --fresh skips Docker migration
This commit is contained in:
@@ -177,6 +177,47 @@ class ManageNativeTests(unittest.TestCase):
|
||||
self.assertEqual(calls[0], ["launchctl", "enable", f"gui/{os.getuid()}/net.a-wan.pipelines"])
|
||||
self.assertIn(["launchctl", "kickstart", f"gui/{os.getuid()}/net.a-wan.pipelines"], calls)
|
||||
|
||||
def test_update_reinstalls_the_same_way_and_restarts(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
source = Path(directory) / "src"
|
||||
source.mkdir()
|
||||
(source / "install.sh").write_text("#!/bin/sh\n")
|
||||
config = self.config(Path(directory))
|
||||
config["source"] = str(source)
|
||||
config["install_args"] = ["--port", "18180"]
|
||||
calls = []
|
||||
done = subprocess.CompletedProcess([], 0)
|
||||
with patch.object(manage, "healthy", return_value=True), \
|
||||
patch.object(manage, "active_runs", return_value=[]), \
|
||||
patch.object(manage.subprocess, "run", side_effect=lambda cmd, **kw: calls.append(cmd) or done), \
|
||||
patch.object(manage, "load", return_value=config), \
|
||||
patch.object(manage, "stop") as stop, patch.object(manage, "start") as start, \
|
||||
patch.object(manage, "report") as report:
|
||||
manage.update(config)
|
||||
self.assertEqual(calls, [["sh", str(source / "install.sh"), "--port", "18180"]])
|
||||
stop.assert_called_once()
|
||||
start.assert_called_once()
|
||||
report.assert_called_once()
|
||||
|
||||
def test_update_waits_for_active_runs(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
source = Path(directory)
|
||||
(source / "install.sh").write_text("#!/bin/sh\n")
|
||||
config = self.config(Path(directory))
|
||||
config["source"] = str(source)
|
||||
with patch.object(manage, "healthy", return_value=True), \
|
||||
patch.object(manage, "active_runs", return_value=[{"id": 1}]), \
|
||||
patch.object(manage.subprocess, "run") as ran:
|
||||
with self.assertRaisesRegex(RuntimeError, "still executing"):
|
||||
manage.update(config)
|
||||
ran.assert_not_called()
|
||||
|
||||
def test_update_needs_a_recorded_source(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
config = self.config(Path(directory))
|
||||
with self.assertRaisesRegex(ValueError, "source checkout"):
|
||||
manage.update(config)
|
||||
|
||||
def test_report_prints_the_server_block_and_access(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
||||
Reference in New Issue
Block a user