Skip to content

Commit

Permalink
Make sure that filesystem scans are returning files in proper order (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech authored Apr 17, 2024
1 parent d44880d commit 0c1747d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,30 @@ public function test_remove_pattern() : void
self::assertFalse($fs->exists($stream->path()));
$fs->rm($dirPath);
}

public function test_that_scan_sort_files_by_path_names() : void
{
$paths = \iterator_to_array(
(new FlysystemFS())
->scan(
new Path(__DIR__ . '/Fixtures/multi_partitions/**/*.txt'),
)
);

self::assertEquals(
[
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-01/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-01/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-02/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-02/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-03/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-03/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-04/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-04/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-05/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-05/country=pl/file.txt'),
],
$paths
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,30 @@ public function test_remove_pattern() : void
self::assertFalse($fs->exists($stream->path()));
$fs->rm($dirPath);
}

public function test_that_scan_sort_files_by_path_names() : void
{
$paths = \iterator_to_array(
(new LocalFilesystem())
->scan(
new Path(__DIR__ . '/Fixtures/multi_partitions/**/*.txt'),
)
);

self::assertEquals(
[
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-01/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-01/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-02/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-02/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-03/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-03/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-04/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-04/country=pl/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-05/country=de/file.txt'),
new Path(__DIR__ . '/Fixtures/multi_partitions/date=2022-01-05/country=pl/file.txt'),
],
$paths
);
}
}

0 comments on commit 0c1747d

Please sign in to comment.