From 2ba11a183908a842ddc45b40bcb0626e9c915f7b Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 15 Jul 2022 20:21:50 +0200 Subject: [PATCH] Return Etag value from saveToS3 method (#24) * Return Etag from saveToS3 method * Update Tests --- src/BrowsershotLambda.php | 4 +++- tests/BrowsershotLambdaTest.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BrowsershotLambda.php b/src/BrowsershotLambda.php index fdfe9ef..472ddb9 100644 --- a/src/BrowsershotLambda.php +++ b/src/BrowsershotLambda.php @@ -60,7 +60,7 @@ protected function throwError(SettledResult $response): void /** * @throws CouldNotTakeBrowsershot */ - public function saveToS3(string $targetPath, string $disk = 's3') + public function saveToS3(string $targetPath, string $disk = 's3'): string { $this->setOption('s3', [ 'path' => $targetPath, @@ -83,5 +83,7 @@ public function saveToS3(string $targetPath, string $disk = 's3') if (empty($output)) { throw CouldNotTakeBrowsershot::chromeOutputEmpty("$targetPath on S3 disk: $disk", $output, $command); } + + return $output; } } diff --git a/tests/BrowsershotLambdaTest.php b/tests/BrowsershotLambdaTest.php index 01deb51..cfdf854 100644 --- a/tests/BrowsershotLambdaTest.php +++ b/tests/BrowsershotLambdaTest.php @@ -83,7 +83,9 @@ it('stores pdf in s3 bucket', function () { $this->assertFalse(Storage::disk('s3')->exists('example.pdf')); - BrowsershotLambda::url('https://example.com')->saveToS3('example.pdf'); + $etag = BrowsershotLambda::url('https://example.com')->saveToS3('example.pdf'); + + $this->assertIsString($etag); $this->assertTrue(Storage::disk('s3')->exists('example.pdf')); Storage::disk('s3')->delete('example.pdf');