Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

test(state): cover sqlite import retry

cyh53889416793d
diff --git a/tests/test_sqlite_state_migration.py b/tests/test_sqlite_state_migration.py
index d2769cfa4..c47fb8347 100644
--- a/tests/test_sqlite_state_migration.py
+++ b/tests/test_sqlite_state_migration.py
@@ -4,6 +4,8 @@ import json
import sqlite3
from pathlib import Path
+import pytest
+
from storage.db import SqliteInvalidationProbe, create_sqlite_engine
from storage.importer import ensure_sqlite_state
from storage.migrations import run_migrations
@@ -81,6 +83,28 @@ def test_legacy_settings_import_does_not_rewrite_source_json(tmp_path: Path) ->
assert settings_path.read_text(encoding="utf-8") == original
+def test_failed_json_import_does_not_mark_complete_and_can_retry(tmp_path: Path) -> None:
+ state_dir = tmp_path / "state"
+ state_dir.mkdir()
+ db_path = state_dir / "vibe.sqlite"
+ (state_dir / "settings.json").write_text("{not-json", encoding="utf-8")
+
+ with pytest.raises(json.JSONDecodeError):
+ ensure_sqlite_state(db_path=db_path, state_dir=state_dir, primary_platform="slack")
+
+ with sqlite3.connect(db_path) as conn:
+ marker = conn.execute(
+ "select value from schema_meta where key = 'json_import_completed_at'",
+ ).fetchone()
+ assert marker is None
+
+ _write_current_settings(state_dir / "settings.json")
+ report = ensure_sqlite_state(db_path=db_path, state_dir=state_dir, primary_platform="slack")
+
+ assert report.imported is True
+ assert report.counts["channel_settings"] == 1
+
+
def test_data_version_probe_detects_external_write(tmp_path: Path) -> None:
db_path = tmp_path / "vibe.sqlite"
run_migrations(db_path)