-
Notifications
You must be signed in to change notification settings - Fork 75
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
1 parent
15671f4
commit 89ca88a
Showing
1 changed file
with
42 additions
and
0 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 |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
/* eslint-env mocha */ | ||
|
||
import * as transactions from '../../src/api/transactions' | ||
import {TaskModel, TransactionModel} from '../../src/model' | ||
import {ObjectId} from 'mongodb' | ||
|
||
describe('calculateTransactionBodiesByteLength()', () => { | ||
it('should calculate the bodies length of a transaction', async () => { | ||
|
@@ -47,3 +49,43 @@ describe('calculateTransactionBodiesByteLength()', () => { | |
lengthObj.length.should.be.exactly(0) | ||
}) | ||
}) | ||
|
||
describe('*createRerunTasks', () => { | ||
const transaction = Object.freeze({ | ||
status: 'Failed', | ||
request: { | ||
timestamp: new Date().toISOString() | ||
}, | ||
updatedBy: { | ||
id: new ObjectId(), | ||
name: 'Test' | ||
} | ||
}) | ||
const userEmail = '[email protected]' | ||
|
||
beforeEach(async () => { | ||
await TransactionModel.deleteMany({}) | ||
await TaskModel.deleteMany({}) | ||
}) | ||
|
||
afterEach(async () => { | ||
await TransactionModel.deleteMany({}) | ||
await TaskModel.deleteMany({}) | ||
}) | ||
|
||
it('should create rerun task', async () => { | ||
await TransactionModel(transaction).save() | ||
await transactions.createRerunTasks({}, 1, userEmail, 0, 0, 'Paused', 1) | ||
const tasks = await TaskModel.find() | ||
tasks.length.should.be.exactly(1) | ||
}) | ||
|
||
it('should create multiple rerun tasks', async () => { | ||
await TransactionModel(transaction).save() | ||
await TransactionModel(transaction).save() | ||
|
||
await transactions.createRerunTasks({}, 1, userEmail, 0, 1, '', 1) | ||
const tasks = await TaskModel.find() | ||
tasks.length.should.be.exactly(2) | ||
}) | ||
}) |