MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / test_migration_handles_invalid_json

Function test_migration_handles_invalid_json

src/context/task_storage.rs:1024–1049  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1022
1023 #[tokio::test]
1024 async fn test_migration_handles_invalid_json() {
1025 let ctx = AppContext::builder().build();
1026 let tsk_env = ctx.tsk_env();
1027 tsk_env.ensure_directories().unwrap();
1028
1029 let data_dir = tsk_env.data_dir();
1030 let json_path = data_dir.join("tasks.json");
1031 let bak_path = data_dir.join("tasks.json.bak");
1032 let db_path = data_dir.join("migration_invalid_test.db");
1033
1034 // Create tasks.json with invalid content
1035 fs::write(&json_path, "not valid json {{{").unwrap();
1036
1037 let storage = TaskStorage::new(db_path).unwrap();
1038
1039 // DB should be empty
1040 let stored_tasks = storage.list_tasks().await.unwrap();
1041 assert_eq!(stored_tasks.len(), 0);
1042
1043 // tasks.json should be renamed to .bak even for invalid JSON
1044 assert!(!json_path.exists());
1045 assert!(bak_path.exists());
1046
1047 // Clean up
1048 let _ = fs::remove_file(&bak_path);
1049 }
1050
1051 #[tokio::test]
1052 async fn test_resolved_config_round_trip() {

Callers

nothing calls this directly

Calls 6

remove_fileFunction · 0.85
tsk_envMethod · 0.80
ensure_directoriesMethod · 0.80
data_dirMethod · 0.80
list_tasksMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected