make tests more robust

This commit is contained in:
Daniel
2020-11-22 10:49:56 +01:00
committed by Daniel Hutzel
parent e15a6192b6
commit b6028721af
9 changed files with 17 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
const { expect } = require('../test')
const cds = require('@sap/cds/lib')
const { expect } = cds.test
const CQL = ([cql]) => cds.parse.cql(cql)
const Foo = { name: 'Foo' }
const Books = { name: 'capire.bookshop.Books' }

View File

@@ -1,7 +1,7 @@
const cds = require('@sap/cds/lib')
const { expect } = cds.test (
const { expect } = require('../test') .run (
'serve', 'AdminService', '--from', '@capire/bookshop,@capire/common', '--in-memory'
).in(__dirname)
)
const cds = require('@sap/cds/lib')
describe('Consuming Services locally', () => {
//

View File

@@ -1,5 +1,5 @@
const { GET, POST, expect } = require('../test') .run ('bookshop')
const cds = require('@sap/cds/lib'); cds.User = cds.User.Privileged // skip auth
const { GET, POST, expect } = cds.test('bookshop').in(__dirname,'..')
describe('Custom Handlers', () => {

View File

@@ -1,5 +1,4 @@
const cds = require('@sap/cds/lib')
const { GET, expect } = cds.test('serve','hello/world.cds').in(__dirname,'..')
const { GET, expect } = require('../test') .run ('serve','hello/world.cds')
describe('Hello world!', () => {

View File

@@ -1,6 +1,5 @@
const cwd = process.cwd(); process.chdir (__dirname) //> only for internal CI/CD@SAP
const {expect} = require('../test')
const cds = require('@sap/cds/lib')
const {expect} = cds.test
// monkey patching older releases:
if (!cds.compile.cdl) cds.compile.cdl = cds.parse
@@ -25,8 +24,6 @@ describe('Hierarchical Data', ()=>{
expect (cds.db.model) .to.exist
})
after(()=> process.chdir(cwd))
it ('supports deeply nested inserts', ()=> INSERT.into (Cats,
{ ID:100, name:'Some Cats...', children:[
{ ID:101, name:'Cat', children:[

6
test/index.js Normal file
View File

@@ -0,0 +1,6 @@
const test = require('@sap/cds/lib/utils/tests').in(__dirname,'..')
module.exports = Object.assign(test,{run:test})
// REVISIT: With upcoming release of @sap/cds this should become:
// module.exports = require('@sap/cds/tests').in(__dirname,'..')

View File

@@ -1,5 +1,5 @@
const { GET, expect } = require('../test') .run ('serve', 'test/localized-data.cds', '--in-memory')
const cds = require('@sap/cds/lib'); cds.User = cds.User.Privileged // skip auth
const { GET, expect } = cds.test ('serve', __dirname+'/localized-data.cds', '--in-memory')
describe('Localized Data', () => {

View File

@@ -1,13 +1,10 @@
const { expect } = require('../test')
const cds = require('@sap/cds/lib')
const cwd = process.cwd(); process.chdir (__dirname) //> only for internal CI/CD@SAP
const {expect} = cds.test
const _model = '@capire/reviews'
cds.User = cds.User.Privileged // hard core monkey patch
describe('Messaging', ()=>{
after(()=> process.chdir(cwd))
it ('should bootstrap sqlite in-memory db', async()=>{
const db = await cds.deploy (_model) .to ('sqlite::memory:')
await db.delete('Reviews')

View File

@@ -1,8 +1,9 @@
const { GET, expect } = require('../test') .run ('bookshop')
const cds = require('@sap/cds/lib'); cds.User = cds.User.Privileged // skip auth
const { GET, expect } = cds.test('bookshop').in(__dirname,'..')
describe('OData Protocol', () => {
it('serves $metadata documents in v4', async () => {
const { headers, status, data } = await GET `/browse/$metadata`
expect(status).to.equal(200)