Skip to content

Commit

Permalink
fix(tests): Add messages so we know what fails
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jan 26, 2024
1 parent 39dcf36 commit 415828e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/lib/Files/ObjectStore/S3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function assertNoUpload($objectUrn) {
'Bucket' => $s3->getBucket(),
'Prefix' => $objectUrn,
]);
$this->assertArrayNotHasKey('Uploads', $uploads);
$this->assertArrayNotHasKey('Uploads', $uploads, 'Assert is not uploaded');
}

public function testEmptyUpload() {
Expand All @@ -125,11 +125,11 @@ public function testEmptyUpload() {
$s3->writeObject('emptystream', $emptyStream);

$this->assertNoUpload('emptystream');
$this->assertTrue($s3->objectExists('emptystream'));
$this->assertTrue($s3->objectExists('emptystream'), 'Object exists on S3');

$thrown = false;
try {
self::assertFalse($s3->readObject('emptystream'));
self::assertFalse($s3->readObject('emptystream'), 'Reading empty stream object should return false');
} catch (\Exception $e) {
// An exception is expected here since 0 byte files are wrapped
// to be read from an empty memory stream in the ObjectStoreStorage
Expand Down Expand Up @@ -164,20 +164,20 @@ public function testFileSizes($size) {
$s3->writeObject('testfilesizes', $sourceStream);

$this->assertNoUpload('testfilesizes');
self::assertTrue($s3->objectExists('testfilesizes'));
self::assertTrue($s3->objectExists('testfilesizes'), 'Object exists on S3');

$result = $s3->readObject('testfilesizes');

// compare first 100 bytes
self::assertEquals(str_repeat('A', 100), fread($result, 100));
self::assertEquals(str_repeat('A', 100), fread($result, 100), 'Compare first 100 bytes');

// compare 100 bytes
fseek($result, $size - 100);
self::assertEquals(str_repeat('A', 100), fread($result, 100));
self::assertEquals(str_repeat('A', 100), fread($result, 100), 'Compare 100 bytes');

// end of file reached
fseek($result, $size);
self::assertTrue(feof($result));
self::assertTrue(feof($result), 'End of file reached');

$this->assertNoUpload('testfilesizes');
}
Expand Down

0 comments on commit 415828e

Please sign in to comment.