Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions: ImageMagick tutorial: Idiomatic & Robustness Improvements #1456

Merged
merged 7 commits into from
Aug 28, 2019
Prev Previous commit
Next Next commit
functions/imagemagick: allow cleanup to fail gracefully
  • Loading branch information
grayside committed Aug 27, 2019
commit a08a2dd935f6498c9bc778955f79e4ee00f6677e
9 changes: 1 addition & 8 deletions functions/imagemagick/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const testFiles = {

describe('functions/imagemagick tests', async () => {
let startFF, stopFF;
// Successfully generated images require cleanup.
let cleanupRequired = false;

before(async () => {
let exists;
Expand Down Expand Up @@ -134,9 +132,7 @@ describe('functions/imagemagick tests', async () => {
.bucket(BLURRED_BUCKET_NAME)
.file(testFiles.offensive)
.exists();

assert.ok(exists, 'File uploaded');
cleanupRequired |= exists;
});

it('blurOffensiveImages detects missing images as safe using Cloud Vision', async () => {
Expand All @@ -159,13 +155,10 @@ describe('functions/imagemagick tests', async () => {
});

after(async () => {
if (!cleanupRequired) {
return;
}
try {
await blurredBucket.file(testFiles.offensive).delete();
} catch (err) {
console.log('Error deleting uploaded file:', err);
console.log('Error deleting uploaded file:', err.message);
}
});
});