|
|
|
@ -54,27 +54,15 @@ function baseModelSqlTests() {
|
|
|
|
|
); |
|
|
|
|
const insertedRow = (await baseModelSql.list())[0]; |
|
|
|
|
|
|
|
|
|
if (isPg(context)) { |
|
|
|
|
inputData.CreatedAt = new Date(inputData.CreatedAt).toISOString(); |
|
|
|
|
inputData.UpdatedAt = new Date(inputData.UpdatedAt).toISOString(); |
|
|
|
|
|
|
|
|
|
insertedRow.CreatedAt = new Date(insertedRow.CreatedAt).toISOString(); |
|
|
|
|
insertedRow.UpdatedAt = new Date(insertedRow.UpdatedAt).toISOString(); |
|
|
|
|
|
|
|
|
|
response.CreatedAt = new Date(response.CreatedAt).toISOString(); |
|
|
|
|
response.UpdatedAt = new Date(response.UpdatedAt).toISOString(); |
|
|
|
|
} else if (isSqlite(context)) { |
|
|
|
|
// append +00:00 to the date string
|
|
|
|
|
inputData.CreatedAt = `${inputData.CreatedAt}+00:00`; |
|
|
|
|
inputData.UpdatedAt = `${inputData.UpdatedAt}+00:00`; |
|
|
|
|
} |
|
|
|
|
inputData.CreatedAt = response.CreatedAt; |
|
|
|
|
inputData.UpdatedAt = response.UpdatedAt; |
|
|
|
|
|
|
|
|
|
expect(insertedRow).to.include(inputData); |
|
|
|
|
expect(insertedRow).to.include(response); |
|
|
|
|
|
|
|
|
|
const rowInsertedAudit = ( |
|
|
|
|
await Audit.baseAuditList(base.id, {}) |
|
|
|
|
).find((audit) => audit.op_sub_type === 'INSERT'); |
|
|
|
|
const rowInsertedAudit = (await Audit.baseAuditList(base.id, {})).find( |
|
|
|
|
(audit) => audit.op_sub_type === 'INSERT', |
|
|
|
|
); |
|
|
|
|
expect(rowInsertedAudit).to.include({ |
|
|
|
|
user: 'test@example.com', |
|
|
|
|
ip: '::ffff:192.0.0.1', |
|
|
|
@ -120,9 +108,9 @@ function baseModelSqlTests() {
|
|
|
|
|
expect(insertedRows[index]).to.include(inputData); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const rowBulkInsertedAudit = ( |
|
|
|
|
await Audit.baseAuditList(base.id, {}) |
|
|
|
|
).find((audit) => audit.op_sub_type === 'BULK_INSERT'); |
|
|
|
|
const rowBulkInsertedAudit = (await Audit.baseAuditList(base.id, {})).find( |
|
|
|
|
(audit) => audit.op_sub_type === 'BULK_INSERT', |
|
|
|
|
); |
|
|
|
|
expect(rowBulkInsertedAudit).to.include({ |
|
|
|
|
user: 'test@example.com', |
|
|
|
|
ip: '::ffff:192.0.0.1', |
|
|
|
@ -197,9 +185,9 @@ function baseModelSqlTests() {
|
|
|
|
|
updatedRows.forEach((row, index) => { |
|
|
|
|
expect(row['Title']).to.equal(`new-test-${index}`); |
|
|
|
|
}); |
|
|
|
|
const rowBulkUpdateAudit = ( |
|
|
|
|
await Audit.baseAuditList(base.id, {}) |
|
|
|
|
).find((audit) => audit.op_sub_type === 'BULK_UPDATE'); |
|
|
|
|
const rowBulkUpdateAudit = (await Audit.baseAuditList(base.id, {})).find( |
|
|
|
|
(audit) => audit.op_sub_type === 'BULK_UPDATE', |
|
|
|
|
); |
|
|
|
|
expect(rowBulkUpdateAudit).to.include({ |
|
|
|
|
user: 'test@example.com', |
|
|
|
|
ip: '::ffff:192.0.0.1', |
|
|
|
@ -248,9 +236,9 @@ function baseModelSqlTests() {
|
|
|
|
|
updatedRows.forEach((row) => { |
|
|
|
|
if (row.id < 5) expect(row['Title']).to.equal('new-1'); |
|
|
|
|
}); |
|
|
|
|
const rowBulkUpdateAudit = ( |
|
|
|
|
await Audit.baseAuditList(base.id, {}) |
|
|
|
|
).find((audit) => audit.op_sub_type === 'BULK_UPDATE'); |
|
|
|
|
const rowBulkUpdateAudit = (await Audit.baseAuditList(base.id, {})).find( |
|
|
|
|
(audit) => audit.op_sub_type === 'BULK_UPDATE', |
|
|
|
|
); |
|
|
|
|
expect(rowBulkUpdateAudit).to.include({ |
|
|
|
|
user: 'test@example.com', |
|
|
|
|
ip: '::ffff:192.0.0.1', |
|
|
|
@ -327,9 +315,9 @@ function baseModelSqlTests() {
|
|
|
|
|
|
|
|
|
|
expect(remainingRows).to.length(6); |
|
|
|
|
|
|
|
|
|
const rowBulkDeleteAudit = ( |
|
|
|
|
await Audit.baseAuditList(base.id, {}) |
|
|
|
|
).find((audit) => audit.op_sub_type === 'BULK_DELETE'); |
|
|
|
|
const rowBulkDeleteAudit = (await Audit.baseAuditList(base.id, {})).find( |
|
|
|
|
(audit) => audit.op_sub_type === 'BULK_DELETE', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
expect(rowBulkDeleteAudit).to.include({ |
|
|
|
|
user: 'test@example.com', |
|
|
|
@ -376,9 +364,9 @@ function baseModelSqlTests() {
|
|
|
|
|
const remainingRows = await baseModelSql.list(); |
|
|
|
|
|
|
|
|
|
expect(remainingRows).to.length(6); |
|
|
|
|
const rowBulkDeleteAudit = ( |
|
|
|
|
await Audit.baseAuditList(base.id, {}) |
|
|
|
|
).find((audit) => audit.op_sub_type === 'BULK_DELETE'); |
|
|
|
|
const rowBulkDeleteAudit = (await Audit.baseAuditList(base.id, {})).find( |
|
|
|
|
(audit) => audit.op_sub_type === 'BULK_DELETE', |
|
|
|
|
); |
|
|
|
|
expect(rowBulkDeleteAudit).to.include({ |
|
|
|
|
user: 'test@example.com', |
|
|
|
|
ip: '::ffff:192.0.0.1', |
|
|
|
|