@@ -814,8 +814,10 @@ func TestNetWriter_WALCreationAndCleanup(t *testing.T) {
814814 // Wait for WAL writes
815815 time .Sleep (1 * time .Second )
816816
817- // Check that WAL files were created
818- walFiles , err := filepath .Glob (filepath .Join (walDir , "*" ))
817+ // Check that WAL segment files were created. rosedb's WAL stores
818+ // segment files inside a per-address subdirectory, so walk the tree
819+ // and inspect regular files (directory sizes are 0 on Windows).
820+ walFiles , err := collectWALFiles (walDir )
819821 if err != nil {
820822 t .Fatalf ("Failed to list WAL files: %v" , err )
821823 }
@@ -825,17 +827,17 @@ func TestNetWriter_WALCreationAndCleanup(t *testing.T) {
825827 }
826828
827829 t .Logf ("Created %d WAL files" , len (walFiles ))
830+ var totalSize int64
828831 for _ , file := range walFiles {
829832 info , err := os .Stat (file )
830833 if err != nil {
831834 continue
832835 }
833836 t .Logf (" %s (size: %d bytes)" , filepath .Base (file ), info .Size ())
834-
835- // Verify the file has content
836- if info .Size () == 0 {
837- t .Errorf ("WAL file %s is empty" , filepath .Base (file ))
838- }
837+ totalSize += info .Size ()
838+ }
839+ if totalSize == 0 {
840+ t .Errorf ("WAL files are empty; expected messages to be written to the WAL" )
839841 }
840842
841843 // Close the writer
@@ -848,7 +850,7 @@ func TestNetWriter_WALCreationAndCleanup(t *testing.T) {
848850 time .Sleep (500 * time .Millisecond )
849851
850852 // Check if WAL files were cleaned up
851- walFilesAfter , err := filepath . Glob ( filepath . Join ( walDir , "*" ) )
853+ walFilesAfter , err := collectWALFiles ( walDir )
852854 if err != nil {
853855 t .Fatalf ("Failed to list WAL files after cleanup: %v" , err )
854856 }
@@ -869,6 +871,24 @@ func TestNetWriter_WALCreationAndCleanup(t *testing.T) {
869871 }
870872}
871873
874+ // collectWALFiles returns all regular files under root. It is used by
875+ // WAL tests instead of filepath.Glob so that segment files nested inside
876+ // a per-address subdirectory are discovered, and so that directory
877+ // entries (whose reported size is 0 on Windows) are excluded.
878+ func collectWALFiles (root string ) ([]string , error ) {
879+ var files []string
880+ err := filepath .WalkDir (root , func (path string , d os.DirEntry , err error ) error {
881+ if err != nil {
882+ return err
883+ }
884+ if ! d .IsDir () {
885+ files = append (files , path )
886+ }
887+ return nil
888+ })
889+ return files , err
890+ }
891+
872892func TestNetWriter_WALTruncation (t * testing.T ) {
873893 // Create a temporary directory for this test
874894 tempDir := t .TempDir ()
@@ -1410,8 +1430,10 @@ func TestNetWriter_WALWriting(t *testing.T) {
14101430 t .Fatalf ("WAL directory was not created: %s" , walDir )
14111431 }
14121432
1413- // Check WAL files
1414- walFiles , err := filepath .Glob (filepath .Join (walDir , "*" ))
1433+ // Check WAL segment files. Walk the tree so that files nested inside
1434+ // per-address subdirectories are discovered and directory entries
1435+ // (which report size 0 on Windows) are excluded.
1436+ walFiles , err := collectWALFiles (walDir )
14151437 if err != nil {
14161438 t .Fatalf ("Failed to list WAL files: %v" , err )
14171439 }
0 commit comments