refactor(backend): phase 3 - add integration tests for config sync (partial)
Add integration test suite with isolated test environment:
- New test file: tests/import_export_sync.rs (149 lines, 3 test cases)
* sync_claude_provider_writes_live_settings: validates SSOT sync to live settings
* create_backup_skips_missing_file: edge case handling for missing config
* create_backup_generates_snapshot_file: verifies backup snapshot creation
- Test infrastructure:
* OnceLock-based isolated HOME directory in temp folder
* Mutex guard to ensure sequential test execution (avoid file system race)
* Automatic cleanup between test runs
Export core APIs for testing (lib.rs):
- AppType, MultiAppConfig, Provider (data structures)
- get_claude_settings_path, read_json_file (config utilities)
- create_backup, sync_current_providers_to_live (sync operations)
- update_settings, AppSettings (settings management)
Adjust visibility:
- import_export::sync_current_providers_to_live: fn -> pub fn
Update documentation:
- Mark Phase 3 as in-progress (🚧) in BACKEND_REFACTOR_PLAN.md
- Document current test coverage scope and pending scenarios
Test results: 7/7 passed (4 unit + 3 integration)
Build time: 0.16s
Next steps:
- Add Codex sync tests (auth.json + config.toml atomic writes)
- Add MCP sync integration tests
- Add end-to-end provider switching tests
This commit is contained in:
@@ -15,6 +15,12 @@ mod speedtest;
|
||||
mod store;
|
||||
mod usage_script;
|
||||
|
||||
pub use app_config::{AppType, MultiAppConfig};
|
||||
pub use config::{get_claude_settings_path, read_json_file};
|
||||
pub use import_export::{create_backup, sync_current_providers_to_live};
|
||||
pub use provider::Provider;
|
||||
pub use settings::{update_settings, AppSettings};
|
||||
|
||||
use store::AppState;
|
||||
use tauri::{
|
||||
menu::{CheckMenuItem, Menu, MenuBuilder, MenuItem},
|
||||
|
||||
Reference in New Issue
Block a user