Skip to content

Commit 766d265

Browse files
committed
fix: address code review comments on imagemagick sample
1 parent e706d49 commit 766d265

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

functions/imagemagick/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ exports.blurOffensiveImages = async event => {
6363
// Blurs the given file using ImageMagick, and uploads it to another bucket.
6464
const blurImage = async (file, blurredBucketName) => {
6565
const tempLocalPath = `/tmp/${path.parse(file.name).base}`;
66-
const tempLocalBlurredPath = `/tmp/blurred-${path.parse(file.name).base}`; // 1. Declarar la variable
66+
const tempLocalBlurredPath = `/tmp/blurred-${path.parse(file.name).base}`;
6767

6868
// Download file from bucket.
6969
try {
@@ -98,6 +98,6 @@ const blurImage = async (file, blurredBucketName) => {
9898

9999
// Delete the temporary file.
100100
await fs.unlink(tempLocalPath);
101-
return fs.unlink(tempLocalBlurredPath);
101+
return await fs.unlink(tempLocalBlurredPath);
102102
};
103103
// [END functions_imagemagick_blur]

functions/imagemagick/test/index.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'use strict';
1616

1717
const assert = require('assert');
18-
const {execSync, spawn} = require('child_process');
18+
const {spawn} = require('child_process');
1919
const {Storage} = require('@google-cloud/storage');
2020
const sinon = require('sinon');
2121
const {request} = require('gaxios');
@@ -62,11 +62,6 @@ async function startFF(port) {
6262
return {ffProc, ffProcHandler};
6363
}
6464

65-
// ImageMagick is available by default in Cloud Run Functions environments
66-
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
67-
// Manually install it for testing only.
68-
//execSync('sudo apt-get install imagemagick -y');
69-
7065
describe('functions/imagemagick tests', () => {
7166
before(async () => {
7267
let exists;
@@ -178,7 +173,7 @@ describe('functions/imagemagick tests', () => {
178173

179174
after(async () => {
180175
try {
181-
// await blurredBucket.file(testFiles.offensive).delete();
176+
await blurredBucket.file(testFiles.offensive).delete();
182177
} catch (err) {
183178
console.log('Error deleting uploaded file:', err.message);
184179
}

0 commit comments

Comments
 (0)