feat: add standard init-db CLI for host install schema ensure
All checks were successful
技能自动化发布 / release (push) Successful in 4s
All checks were successful
技能自动化发布 / release (push) Successful in 4s
This commit is contained in:
@@ -27,6 +27,7 @@ class TestCliSmoke(unittest.TestCase):
|
||||
out = buf.getvalue()
|
||||
self.assertIn("通用业务技能模板", out)
|
||||
self.assertIn("health", out)
|
||||
self.assertIn("init-db", out)
|
||||
|
||||
def test_health_zero(self) -> None:
|
||||
old_record = os.environ.get("OPENCLAW_RECORD_VIDEO")
|
||||
@@ -57,6 +58,26 @@ class TestCliSmoke(unittest.TestCase):
|
||||
self.assertIn("skill", payload)
|
||||
self.assertEqual(payload["skill"], SKILL_SLUG)
|
||||
|
||||
def test_init_db_creates_database_and_is_idempotent(self) -> None:
|
||||
with IsolatedDataRoot(user_id="_cli_init_db"):
|
||||
config.reset_cache()
|
||||
buf = io.StringIO()
|
||||
with redirect_stdout(buf), redirect_stderr(io.StringIO()):
|
||||
rc = main(["init-db"])
|
||||
self.assertEqual(rc, 0)
|
||||
payload = json.loads(buf.getvalue().strip())
|
||||
self.assertTrue(payload["ok"])
|
||||
self.assertEqual(payload["skill"], SKILL_SLUG)
|
||||
self.assertTrue(os.path.isfile(payload["db_path"]))
|
||||
|
||||
buf2 = io.StringIO()
|
||||
with redirect_stdout(buf2), redirect_stderr(io.StringIO()):
|
||||
rc2 = main(["init-db"])
|
||||
self.assertEqual(rc2, 0)
|
||||
payload2 = json.loads(buf2.getvalue().strip())
|
||||
self.assertTrue(payload2["ok"])
|
||||
self.assertEqual(payload2["db_path"], payload["db_path"])
|
||||
|
||||
def test_logs_empty_returns_zero(self) -> None:
|
||||
with IsolatedDataRoot():
|
||||
buf = io.StringIO()
|
||||
|
||||
Reference in New Issue
Block a user