Skip to content

Commit 0c2fbac

Browse files
author
RTLcoil
authored
Make sure Uploader tests cleanup after themselves (#401)
- Add an upload tag to uploads done through specHelper
1 parent b1e23fc commit 0c2fbac

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/spechelper.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ exports.ICON_FILE = "test/.resources/favicon.ico";
2929
exports.VIDEO_URL = "http://res.cloudinary.com/demo/video/upload/dog.mp4";
3030
exports.IMAGE_URL = "http://res.cloudinary.com/demo/image/upload/sample";
3131

32+
const { TEST_TAG } = require('./testUtils/testConstants').TAGS;
33+
3234
exports.SAMPLE_VIDEO_SOURCES = [
3335
{
3436
type: 'mp4',
@@ -229,10 +231,16 @@ exports.setupCache = function () {
229231
};
230232

231233
/**
232-
Upload an image to be tested on.
233-
@callback the callback receives the public_id of the uploaded image
234-
*/
235-
exports.uploadImage = function (options) {
234+
* Upload an image to be tested on.
235+
*
236+
* @param {object} options Optional options to use when uploading the test image
237+
* @returns {object} A response object returned from the upload API
238+
*/
239+
exports.uploadImage = function (options = {}) {
240+
// Ensure that options at the very least contains the TEST_TAG
241+
options.tags = options.tags || [];
242+
if (!options.tags.includes(TEST_TAG)) options.tags.push(TEST_TAG);
243+
236244
return cloudinary.v2.uploader.upload(exports.IMAGE_FILE, options);
237245
};
238246

0 commit comments

Comments
 (0)