Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: postgres build plugin w --production #1018

Merged
merged 9 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
cache: 'npm'

- run: npm ci
- run: npm install -g @sap/cds-dk
- run: npm run lint
- id: hxe
uses: ./.github/actions/hxe
Expand Down
2 changes: 1 addition & 1 deletion postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"postgres": {
"impl": "@cap-js/postgres",
"kind": "sqlite",
"kind": "postgres",
"dialect": "postgres",
"vcap": {
"label": "postgresql-db"
Expand Down
30 changes: 30 additions & 0 deletions postgres/test/cds-build.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

// make sure the build plugin works

const path = require('path')
const fs = require('fs')
const { execSync } = require('child_process')
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')

// delete the generated folder after each test
afterEach(() => {
if (fs.existsSync(genDir)) fs.rmSync(genDir, { recursive: true })
})

describe('cds build plugin', () => {
const { expect } = cds.test
test('should run pg build with explicit build task', () => {
execSync('npx cds build --for postgres', { cwd: workDir })
expect(fs.existsSync(path.join(dbDest, 'csn.json'))).to.be.true
})

test('should run pg build with production profile', () => {
execSync('npx cds build --production', { cwd: workDir })
expect(fs.existsSync(path.join(dbDest, 'csn.json'))).to.be.true
})
})
3 changes: 3 additions & 0 deletions postgres/test/tiny-sample/db/data/my.bookshop-Books.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ID,title,stock
1,Wuthering Heights,100
2,Jane Eyre,500
7 changes: 7 additions & 0 deletions postgres/test/tiny-sample/db/schema.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace my.bookshop;

entity Books {
key ID : Integer;
title : String;
stock : Integer;
}
8 changes: 8 additions & 0 deletions postgres/test/tiny-sample/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "tiny-sample",
"version": "1.0.0",
"description": "A simple CAP project, to test the build plugin",
"dependencies": {
"@cap-js/postgres": "../../."
}
}
5 changes: 5 additions & 0 deletions postgres/test/tiny-sample/srv/cat-service.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using my.bookshop as my from '../db/schema';

service CatalogService {
@readonly entity Books as projection on my.Books;
}