@@ -581,7 +581,7 @@ func TestSysErrorHandlingDecode(t *testing.T) {
581581 }
582582}
583583
584- // System test for creating metadata (without returning layout content)
584+ // System test for creating metadata
585585func TestSysCreateMetadata (t * testing.T ) {
586586 // Create RaptorQ processor with default settings
587587 processor , err := NewDefaultRaptorQProcessor ()
@@ -598,33 +598,28 @@ func TestSysCreateMetadata(t *testing.T) {
598598 ctx := NewTestContext (t , 1024 * 1024 ) // 1MB file
599599 defer ctx .Cleanup ()
600600
601- // Create metadata without returning layout (save to file)
602- res , err := processor .CreateMetadata (ctx .InputFile , ctx .SymbolsDir , 0 , false )
601+ // Create layout file path
602+ layoutPath := filepath .Join (ctx .TempDir , "layout.json" )
603+
604+ // Create metadata
605+ res , err := processor .CreateMetadata (ctx .InputFile , layoutPath , 0 )
603606 if err != nil {
604607 t .Fatalf ("Failed to create metadata: %v" , err )
605608 }
606609
607610 // Verify the layout file exists
608- layoutPath := res .LayoutFilePath
609611 if _ , err := os .Stat (layoutPath ); os .IsNotExist (err ) {
610612 t .Fatalf ("Layout file not found at %s" , layoutPath )
611613 }
612614
613615 // Verify the result contains expected fields
614- if res .SymbolsDirectory == "" {
615- t .Fatal ("Result should contain symbols_directory" )
616- }
617616 if res .LayoutFilePath == "" {
618617 t .Fatal ("Result should contain layout_file_path" )
619618 }
620619}
621620
622- // System test for creating metadata with layout content returned
623- func TestSysCreateMetadataReturnLayout (t * testing.T ) {
624- // Note: Since our current implementation is a temporary wrapper around EncodeFile,
625- // we can't fully test the returnLayout parameter yet. This test will need to be
626- // updated when the full implementation is complete.
627-
621+ // System test for creating metadata with specific block size
622+ func TestSysCreateMetadataWithBlockSize (t * testing.T ) {
628623 // Create RaptorQ processor with default settings
629624 processor , err := NewDefaultRaptorQProcessor ()
630625 if err != nil {
@@ -637,22 +632,33 @@ func TestSysCreateMetadataReturnLayout(t *testing.T) {
637632 }()
638633
639634 // Create test context with input file
640- ctx := NewTestContext (t , 1024 * 1024 ) // 1MB file
635+ ctx := NewTestContext (t , 5 * 1024 * 1024 ) // 5MB file
641636 defer ctx .Cleanup ()
642637
643- // Create metadata with returnLayout=true (currently uses the same code path)
644- res , err := processor .CreateMetadata (ctx .InputFile , ctx .SymbolsDir , 0 , true )
638+ // Create layout file path
639+ layoutPath := filepath .Join (ctx .TempDir , "layout_with_blocksize.json" )
640+
641+ // Create metadata with specific block size
642+ blockSize := 1024 * 1024 // 1MB blocks
643+ res , err := processor .CreateMetadata (ctx .InputFile , layoutPath , blockSize )
645644 if err != nil {
646- t .Fatalf ("Failed to create metadata with returnLayout=true : %v" , err )
645+ t .Fatalf ("Failed to create metadata with specific block size : %v" , err )
647646 }
648647
649- // Verify the layout file exists (when full implementation is done, this should be skipped)
650- layoutPath := res .LayoutFilePath
648+ // Verify the layout file exists
651649 if _ , err := os .Stat (layoutPath ); os .IsNotExist (err ) {
652650 t .Fatalf ("Layout file not found at %s" , layoutPath )
653651 }
654652
655- // TODO: When full implementation is complete, verify the result contains layout_content field
653+ // Verify the result contains expected fields
654+ if res .LayoutFilePath == "" {
655+ t .Fatal ("Result should contain layout_file_path" )
656+ }
657+
658+ // Verify the blocks information is present
659+ if len (res .Blocks ) == 0 {
660+ t .Fatal ("Result should contain blocks information" )
661+ }
656662}
657663
658664// Go-specific test for FFI interactions
@@ -1112,20 +1118,22 @@ func BenchmarkCreateMetadata1MB(b *testing.B) {
11121118 ctx := setupBenchmarkEnv (b , SIZE_1MB )
11131119 defer ctx .Cleanup ()
11141120
1121+ // Create layout file path
1122+ layoutPath := filepath .Join (ctx .TempDir , "layout.json" )
1123+
11151124 // Reset timer before starting the benchmark loop
11161125 b .ResetTimer ()
11171126
11181127 // Run the benchmark
11191128 for i := 0 ; i < b .N ; i ++ {
1120- _ , err := processor .CreateMetadata (ctx .InputFile , ctx . SymbolsDir , 0 , false )
1129+ _ , err := processor .CreateMetadata (ctx .InputFile , layoutPath , 0 )
11211130 if err != nil {
11221131 b .Fatalf ("Failed to create metadata: %v" , err )
11231132 }
11241133
1125- // Clean symbols directory for next iteration
1134+ // Remove layout file for next iteration
11261135 if i < b .N - 1 {
1127- os .RemoveAll (ctx .SymbolsDir )
1128- os .MkdirAll (ctx .SymbolsDir , 0755 )
1136+ os .Remove (layoutPath )
11291137 }
11301138 }
11311139}
@@ -1147,20 +1155,22 @@ func BenchmarkCreateMetadata10MB(b *testing.B) {
11471155 ctx := setupBenchmarkEnv (b , SIZE_10MB )
11481156 defer ctx .Cleanup ()
11491157
1158+ // Create layout file path
1159+ layoutPath := filepath .Join (ctx .TempDir , "layout_10mb.json" )
1160+
11501161 // Reset timer before starting the benchmark loop
11511162 b .ResetTimer ()
11521163
11531164 // Run the benchmark
11541165 for i := 0 ; i < b .N ; i ++ {
1155- _ , err := processor .CreateMetadata (ctx .InputFile , ctx . SymbolsDir , 0 , true ) // with returnLayout=true
1166+ _ , err := processor .CreateMetadata (ctx .InputFile , layoutPath , 0 )
11561167 if err != nil {
11571168 b .Fatalf ("Failed to create metadata: %v" , err )
11581169 }
11591170
1160- // Clean symbols directory for next iteration
1171+ // Remove layout file for next iteration
11611172 if i < b .N - 1 {
1162- os .RemoveAll (ctx .SymbolsDir )
1163- os .MkdirAll (ctx .SymbolsDir , 0755 )
1173+ os .Remove (layoutPath )
11641174 }
11651175 }
11661176}
@@ -1185,20 +1195,22 @@ func BenchmarkCreateMetadata100MB(b *testing.B) {
11851195 // Use block size for large file
11861196 blockSize := 5 * 1024 * 1024 // 5MB blocks
11871197
1198+ // Create layout file path
1199+ layoutPath := filepath .Join (ctx .TempDir , "layout_100mb.json" )
1200+
11881201 // Reset timer before starting the benchmark loop
11891202 b .ResetTimer ()
11901203
11911204 // Run the benchmark
11921205 for i := 0 ; i < b .N ; i ++ {
1193- _ , err := processor .CreateMetadata (ctx .InputFile , ctx . SymbolsDir , blockSize , false )
1206+ _ , err := processor .CreateMetadata (ctx .InputFile , layoutPath , blockSize )
11941207 if err != nil {
11951208 b .Fatalf ("Failed to create metadata: %v" , err )
11961209 }
11971210
1198- // Clean symbols directory for next iteration
1211+ // Remove layout file for next iteration
11991212 if i < b .N - 1 {
1200- os .RemoveAll (ctx .SymbolsDir )
1201- os .MkdirAll (ctx .SymbolsDir , 0755 )
1213+ os .Remove (layoutPath )
12021214 }
12031215 }
12041216}
0 commit comments