Skip to content

Commit

Permalink
chore(test): test with persistent outbox (#72)
Browse files Browse the repository at this point in the history
note: with old db, the persistent outbox adds a delay
  • Loading branch information
sjvans authored Dec 8, 2023
1 parent 51bbf86 commit fa7fb2b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
},
"cds": {
"requires": {
"[test]": {
"outbox": "persistent-outbox"
},
"audit-log": {
"handle": [
"READ",
Expand Down
9 changes: 8 additions & 1 deletion test/personal-data/crud.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const cds = require('@sap/cds')

const { POST, PATCH, GET, DELETE, data } = cds.test().in(__dirname)
const { POST: _POST, PATCH: _PATCH, GET: _GET, DELETE: _DELETE, data } = cds.test().in(__dirname)

// with old db, the persistent outbox adds a delay
const wait = require('util').promisify(setTimeout)
const POST = (...args) => _POST(...args).then(async res => (await wait(7), res))
const PATCH = (...args) => _PATCH(...args).then(async res => (await wait(7), res))
const GET = (...args) => _GET(...args).then(async res => (await wait(7), res))
const DELETE = (...args) => _DELETE(...args).then(async res => (await wait(7), res))

// TODO: @cap-js/sqlite doesn't support structured properties
// // needed for testing structured properties
Expand Down
9 changes: 8 additions & 1 deletion test/personal-data/fiori.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const cds = require('@sap/cds')

const { POST, PATCH, GET, DELETE, data } = cds.test().in(__dirname)
const { POST: _POST, PATCH: _PATCH, GET: _GET, DELETE: _DELETE, data } = cds.test().in(__dirname)

// with old db, the persistent outbox adds a delay
const wait = require('util').promisify(setTimeout)
const POST = (...args) => _POST(...args).then(async res => (await wait(7), res))
const PATCH = (...args) => _PATCH(...args).then(async res => (await wait(7), res))
const GET = (...args) => _GET(...args).then(async res => (await wait(7), res))
const DELETE = (...args) => _DELETE(...args).then(async res => (await wait(7), res))

const _logger = require('../utils/logger')({ debug: true })
cds.log.Logger = _logger
Expand Down
6 changes: 5 additions & 1 deletion test/personal-data/handle.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const cds = require('@sap/cds')

const { GET } = cds.test().in(__dirname)
let { GET: _GET } = cds.test().in(__dirname)

// with old db, the persistent outbox adds a delay
const wait = require('util').promisify(setTimeout)
const GET = (...args) => _GET(...args).then(async res => (await wait(7), res))

cds.env.requires['audit-log'].handle = ['WRITE']

Expand Down

0 comments on commit fa7fb2b

Please sign in to comment.