Skip to content

Commit

Permalink
fix(server) Make CICERO_DATA default to CICERO_DIR
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Apr 7, 2020
1 parent e31f118 commit 2cefbc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/cicero-server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const Engine = require('@accordproject/cicero-engine').Engine;
if(!process.env.CICERO_DIR) {
throw new Error('You must set the CICERO_DIR environment variable.');
} else if(!process.env.CICERO_DATA) {
throw new Error('You must set the CICERO_DATA environment variable.');
// CICERO_DATA defaults to CICERO_DIR if absent
process.env.CICERO_DATA = process.env.CICERO_DIR;
}

const PORT = process.env.PORT | 6001;
Expand Down
17 changes: 9 additions & 8 deletions packages/cicero-server/test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,24 @@ const parseBody = {
};
const draftText = 'Late Delivery and Penalty. In case of delayed delivery except for Force Majeure cases, the Seller shall pay to the Buyer for every 9 days of delay penalty amounting to 7.0% of the total value of the Equipment whose delivery has been delayed. Any fractional part of a days is to be considered a full days. The total amount of penalty shall not however, exceed 2.0% of the total value of the Equipment involved in late delivery. If the delay is more than 2 weeks, the Buyer is entitled to terminate this Contract.';

describe('cicero-server bad CICERO_DIR environment', () => {
describe('cicero-server environment', () => {
beforeEach(()=>{
process.env.CICERO_DIR = './test/data1';
process.env.CICERO_DATA = './test/data2';
});

it('/should fail to start the server without CICERO_DIR defined', async () => {
delete process.env.CICERO_DIR;
console.log('ENV ' + JSON.stringify(process.env.CICERO_DIR));
(() => require('../app')).should.throw('You must set the CICERO_DIR environment variable.');
process.env.CICERO_DIR = './test/data';
decache('../app');
});

});

describe('cicero-server bad CICERO_DATA environment', () => {

it('/should fail to start the server without CICERO_DATA defined', async () => {
delete process.env.CICERO_DATA;
(() => require('../app')).should.throw('You must set the CICERO_DATA environment variable.');
process.env.CICERO_DATA = './test/data';
const server = require('../app');
process.env.CICERO_DATA.should.eql(process.env.CICERO_DIR);
server.close();
decache('../app');
});

Expand Down

0 comments on commit 2cefbc9

Please sign in to comment.