]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(tests): Add messages to assertions to explain what failed 41003/head
authorJoas Schilling <coding@schilljs.com>
Fri, 26 Jan 2024 19:38:43 +0000 (20:38 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 26 Jan 2024 19:46:14 +0000 (20:46 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
tests/lib/Files/ObjectStore/S3Test.php

index 33130a152a1e164f0389da84f28a1955815b7bb4..c8333ca1ea38d16b3982c13d8fb1d47c0611bcf6 100644 (file)
@@ -113,7 +113,7 @@ class S3Test extends ObjectStoreTest {
                        'Bucket' => $s3->getBucket(),
                        'Prefix' => $objectUrn,
                ]);
-               $this->assertArrayNotHasKey('Uploads', $uploads);
+               $this->assertArrayNotHasKey('Uploads', $uploads, 'Assert is not uploaded');
        }
 
        public function testEmptyUpload() {
@@ -125,11 +125,11 @@ class S3Test extends ObjectStoreTest {
                $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
@@ -164,20 +164,20 @@ class S3Test extends ObjectStoreTest {
                $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
+               // compare last 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 last 100 bytes');
 
                // end of file reached
                fseek($result, $size);
-               self::assertTrue(feof($result));
+               self::assertTrue(feof($result), 'End of file reached');
 
                $this->assertNoUpload('testfilesizes');
        }