@@ -6,6 +6,7 @@ use crate::common::sample_node;
66#[ cfg( unix) ]
77use std:: os:: unix:: fs:: symlink;
88use tempfile:: TempDir ;
9+ use tracedecay:: branch_meta:: BranchMeta ;
910use tracedecay:: global_db:: GlobalDb ;
1011use tracedecay:: lifecycle_lease:: acquire_exclusive_for_profile;
1112use tracedecay:: migrate:: inventory:: {
@@ -48,6 +49,14 @@ fn canonical_temp_path(path: &Path) -> PathBuf {
4849 path. canonicalize ( ) . unwrap_or_else ( |_| path. to_path_buf ( ) )
4950}
5051
52+ fn write_valid_branch_meta ( path : & Path ) {
53+ fs:: write (
54+ path,
55+ serde_json:: to_vec_pretty ( & BranchMeta :: new ( "main" ) ) . unwrap ( ) ,
56+ )
57+ . unwrap ( ) ;
58+ }
59+
5160#[ cfg( unix) ]
5261#[ test]
5362fn save_manifest_rejects_symlinked_parent_components ( ) {
@@ -390,11 +399,7 @@ fn verify_manifest_validates_profile_store_manifest_registry_records() {
390399 fs:: create_dir_all ( & data_root) . unwrap ( ) ;
391400 fs:: write ( data_root. join ( "tracedecay.db" ) , b"graph" ) . unwrap ( ) ;
392401 fs:: write ( data_root. join ( "sessions.db" ) , b"sessions" ) . unwrap ( ) ;
393- fs:: write (
394- data_root. join ( "branch-meta.json" ) ,
395- r#"{"default_branch":"main","branches":{}}"# ,
396- )
397- . unwrap ( ) ;
402+ write_valid_branch_meta ( & data_root. join ( "branch-meta.json" ) ) ;
398403 let store_manifest = StoreManifest {
399404 schema_version : STORE_MANIFEST_SCHEMA_VERSION ,
400405 project_id : Some ( "proj_123" . to_string ( ) ) ,
@@ -492,11 +497,7 @@ async fn verify_manifest_accepts_logically_equal_sqlite_artifacts_with_different
492497 target. close ( ) ;
493498 assert_ne ! ( fs:: read( & source_db) . unwrap( ) , fs:: read( & target_db) . unwrap( ) ) ;
494499
495- fs:: write (
496- data_root. join ( "branch-meta.json" ) ,
497- r#"{"default_branch":"main","branches":{}}"# ,
498- )
499- . unwrap ( ) ;
500+ write_valid_branch_meta ( & data_root. join ( "branch-meta.json" ) ) ;
500501 fs:: write ( data_root. join ( "sessions.db" ) , b"sessions" ) . unwrap ( ) ;
501502 let store_manifest = StoreManifest {
502503 schema_version : STORE_MANIFEST_SCHEMA_VERSION ,
@@ -578,7 +579,7 @@ fn apply_migration_manifest_stops_at_verified_before_cutover() {
578579 fs:: create_dir_all ( & data_dir) . unwrap ( ) ;
579580 fs:: write ( & graph_db, b"graph" ) . unwrap ( ) ;
580581 fs:: write ( & sessions_db, b"sessions" ) . unwrap ( ) ;
581- fs :: write ( & branch_meta, r#"{"default_branch":"main","branches":{}}"# ) . unwrap ( ) ;
582+ write_valid_branch_meta ( & branch_meta) ;
582583 let mut manifest = build_plan_manifest (
583584 MigrationInventory {
584585 stores : vec ! [ StoreInventory {
@@ -604,7 +605,7 @@ fn apply_migration_manifest_stops_at_verified_before_cutover() {
604605 StoreArtifact {
605606 kind: "branch_meta" . to_string( ) ,
606607 path: branch_meta. clone( ) ,
607- size_bytes: 39 ,
608+ size_bytes: fs :: metadata ( & branch_meta ) . unwrap ( ) . len ( ) ,
608609 } ,
609610 ] ,
610611 } ] ,
@@ -649,11 +650,7 @@ fn finalize_migration_apply_marks_cutover_complete() {
649650 let profile_root = root. join ( "profile" ) ;
650651 fs:: create_dir_all ( & data_dir) . unwrap ( ) ;
651652 fs:: write ( & graph_db, b"graph" ) . unwrap ( ) ;
652- fs:: write (
653- data_dir. join ( "branch-meta.json" ) ,
654- r#"{"default_branch":"main","branches":{}}"# ,
655- )
656- . unwrap ( ) ;
653+ write_valid_branch_meta ( & data_dir. join ( "branch-meta.json" ) ) ;
657654 let mut manifest = build_plan_manifest (
658655 MigrationInventory {
659656 stores : vec ! [ StoreInventory {
@@ -944,7 +941,7 @@ fn migrate_apply_copies_single_store_and_cuts_over_profile_shard() {
944941 fs:: create_dir_all ( & data_dir) . unwrap ( ) ;
945942 fs:: write ( & graph_db, b"graph" ) . unwrap ( ) ;
946943 fs:: write ( & sessions_db, b"sessions" ) . unwrap ( ) ;
947- fs :: write ( & branch_meta, r#"{"default_branch":"main","branches":{}}"# ) . unwrap ( ) ;
944+ write_valid_branch_meta ( & branch_meta) ;
948945 let manifest = build_plan_manifest (
949946 MigrationInventory {
950947 stores : vec ! [ StoreInventory {
@@ -970,7 +967,7 @@ fn migrate_apply_copies_single_store_and_cuts_over_profile_shard() {
970967 StoreArtifact {
971968 kind: "branch_meta" . to_string( ) ,
972969 path: branch_meta. clone( ) ,
973- size_bytes: 39 ,
970+ size_bytes: fs :: metadata ( & branch_meta ) . unwrap ( ) . len ( ) ,
974971 } ,
975972 ] ,
976973 } ] ,
@@ -1185,11 +1182,7 @@ fn migrate_reconstruct_reports_registry_plans_without_applying_them() {
11851182 fs:: create_dir_all ( & project) . unwrap ( ) ;
11861183 fs:: create_dir_all ( & data_root) . unwrap ( ) ;
11871184 fs:: write ( data_root. join ( "tracedecay.db" ) , b"graph" ) . unwrap ( ) ;
1188- fs:: write (
1189- data_root. join ( "branch-meta.json" ) ,
1190- r#"{"default_branch":"main","branches":{}}"# ,
1191- )
1192- . unwrap ( ) ;
1185+ write_valid_branch_meta ( & data_root. join ( "branch-meta.json" ) ) ;
11931186 let store_manifest = StoreManifest {
11941187 schema_version : STORE_MANIFEST_SCHEMA_VERSION ,
11951188 project_id : Some ( "proj_123" . to_string ( ) ) ,
0 commit comments