Skip to content

Commit 7234786

Browse files
committed
chore: update tests
1 parent bb09e41 commit 7234786

File tree

1 file changed

+16
-36
lines changed

1 file changed

+16
-36
lines changed

tests/NARTest.php

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,10 @@ public function testHashComparisonWithNix(string $path): void
3232
self::assertSame((new NAR())->hash($path), $nixHash);
3333
}
3434

35-
public static function provideHashCases(): iterable
36-
{
37-
yield [
38-
realpath(__DIR__.'/fixtures/fs/test.md'),
39-
'sha256-8Zli5QunHMIWw0Qr61FCdl2CLeLtBXUrC80Tw8PzaBY=',
40-
];
41-
42-
yield [
43-
realpath(__DIR__.'/fixtures/fs/dir1'),
44-
'sha256-WLBm1CL8lkhnV5HwP8oFwQjb00MU/VpCeuqkLzWTrO8=',
45-
];
46-
47-
yield [
48-
realpath(__DIR__.'/fixtures/fs/'),
49-
'sha256-o6L3G/JHuNm8sbq+/YBUjv/zBrlbj5854+1FkZoLGPY=',
50-
];
51-
}
52-
53-
public function testDumpAndUnpack(): void
35+
#[DataProvider('provideHashCases')]
36+
public function testDumpAndUnpack(string $path): void
5437
{
55-
$source = realpath(__DIR__.'/fixtures/fs');
38+
$source = $path;
5639
$this->narFile = tempnam(sys_get_temp_dir(), 'nar-test-');
5740
$this->destination = sys_get_temp_dir().'/nar-unpack-'.uniqid();
5841

@@ -71,25 +54,22 @@ public function testDumpAndUnpack(): void
7154
self::assertSame($sourceHash, $destinationHash);
7255
}
7356

74-
public function testDumpToStdoutAndUnpack(): void
57+
public static function provideHashCases(): iterable
7558
{
76-
$nar = new NAR();
77-
$source = realpath(__DIR__.'/fixtures/fs');
78-
$this->narFile = tempnam(sys_get_temp_dir(), 'nar-test-');
79-
$this->destination = sprintf('%s/nar-unpack-%s', sys_get_temp_dir(), uniqid());
80-
81-
$handle = fopen($this->narFile, 'w');
82-
foreach ($nar->stream($source) as $chunk) {
83-
fwrite($handle, $chunk);
84-
}
85-
fclose($handle);
59+
yield [
60+
realpath(__DIR__.'/fixtures/fs/test.md'),
61+
'sha256-8Zli5QunHMIWw0Qr61FCdl2CLeLtBXUrC80Tw8PzaBY=',
62+
];
8663

87-
$nar->extract($this->narFile, $this->destination);
64+
yield [
65+
realpath(__DIR__.'/fixtures/fs/dir1'),
66+
'sha256-WLBm1CL8lkhnV5HwP8oFwQjb00MU/VpCeuqkLzWTrO8=',
67+
];
8868

89-
self::assertSame(
90-
$nar->computeHashes($source),
91-
$nar->computeHashes($this->destination)
92-
);
69+
yield [
70+
realpath(__DIR__.'/fixtures/fs/'),
71+
'sha256-o6L3G/JHuNm8sbq+/YBUjv/zBrlbj5854+1FkZoLGPY=',
72+
];
9373
}
9474

9575
protected function tearDown(): void

0 commit comments

Comments
 (0)