-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { type Job } from 'bullmq'; | ||
import imageProcessingJob from '../../src/jobs/imageProcessing.job'; | ||
|
||
describe('imageProcessingJob', () => { | ||
it('should process the image successfully', async () => { | ||
const imageUrl = 'https://example.com/image.jpg'; | ||
const jobData = { imageUrl }; | ||
const job: Partial<Job> = { | ||
id: 'job-id', | ||
name: 'image-processing', | ||
data: jobData, | ||
// Mock other attributes as needed | ||
}; | ||
|
||
await expect(imageProcessingJob(job as Job)).resolves.toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { type Job } from "bullmq"; | ||
|
||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
const imageProcessingJob = async function (job: Job): Promise<void> { | ||
// Define the processing logic for image processing jobs | ||
const { imageUrl } = job.data; // Assuming the job data contains the URL of the image to be processed | ||
|
||
try { | ||
// Perform image processing logic here | ||
console.log(`Processing image: ${imageUrl}`); | ||
|
||
// Simulating image processing time | ||
await new Promise((resolve) => setTimeout(resolve, 3000)); | ||
|
||
console.log('Image processing completed'); | ||
} catch (error) { | ||
console.error('Error processing image:', error); | ||
throw new Error('Failed to process image'); // Throw an error if image processing fails | ||
} | ||
} | ||
|
||
export default imageProcessingJob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters