Skip to content

Commit

Permalink
Finalise test
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady committed Feb 19, 2025
1 parent b3db6fd commit 8d2fb6d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions postgres/test/cds-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const cds = require('../../test/cds.js')

const workDir = path.join(__dirname, 'tiny-sample')
const genDir = path.join(workDir, 'gen')
const dbDest = path.join(genDir, 'pg/db')
const pgDest = path.join(genDir, 'pg')
const dbDest = path.join(pgDest, 'db')

// delete the generated folder after each test
afterEach(() => {
Expand All @@ -29,8 +30,10 @@ describe('cds build plugin', () => {
})

test('should retain assert_integrity setting', () => {
execSync('CDS_FEATURES_ASSERT__INTEGRITY=db npx cds build --production', { cwd: workDir })
expect(fs.existsSync(path.join(dbDest, 'csn.json'))).to.be.true
// TODO: find constraints in csn.json
execSync('npx cds build --production', { cwd: workDir })
const packageJson = require(path.join(pgDest, 'package.json'))
expect(packageJson.cds?.features?.assert_integrity).to.equal('db')
const ddl = String(execSync('npx cds deploy --dry', { cwd: workDir }))
expect(ddl).to.contain('REFERENCES')
})
})
5 changes: 5 additions & 0 deletions postgres/test/tiny-sample/db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ entity Books {
key ID : Integer;
title : String;
stock : Integer;
author : Association to Authors;
}

entity Authors {
key ID : Integer;
}
5 changes: 5 additions & 0 deletions postgres/test/tiny-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"description": "A simple CAP project, to test the build plugin",
"dependencies": {
"@cap-js/postgres": "../../."
},
"cds": {
"features": {
"assert_integrity": "db"
}
}
}

0 comments on commit 8d2fb6d

Please sign in to comment.