forked from accordproject/concerto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(declarations): move declaration uniqueness check to model fi…
…le (accordproject#794) * refactor(declarations): Move unique name check to model file. Signed-off-by: Ertugrul Karademir <[email protected]> * refactor(test): move validation checks for duplicate class to model file Signed-off-by: Ertugrul Karademir <[email protected]> * test: empty commit to trigger test Signed-off-by: Ertugrul Karademir <[email protected]> --------- Signed-off-by: Ertugrul Karademir <[email protected]>
- Loading branch information
1 parent
65d6f7c
commit e3c433c
Showing
3 changed files
with
53 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,10 +44,12 @@ describe('ModelFile', () => { | |
const carLeaseModel = fs.readFileSync(path.resolve(__dirname, '../data/model/carlease.cto'), 'utf8'); | ||
let modelManager; | ||
let sandbox; | ||
let introspectUtils; | ||
|
||
beforeEach(() => { | ||
modelManager = new ModelManager(); | ||
Util.addComposerModel(modelManager); | ||
introspectUtils = new IntrospectUtils(modelManager); | ||
sandbox = sinon.createSandbox(); | ||
}); | ||
|
||
|
@@ -204,6 +206,41 @@ describe('ModelFile', () => { | |
|
||
describe('#validate', () => { | ||
|
||
it('should throw when asset name is duplicted in a modelfile', () => { | ||
let asset = introspectUtils.loadModelFile('test/data/parser/classdeclaration.dupeassetname.cto'); | ||
(() => { | ||
asset.validate(); | ||
}).should.throw(/Duplicate class/); | ||
}); | ||
|
||
it('should throw when transaction name is duplicted in a modelfile', () => { | ||
let asset = introspectUtils.loadModelFile('test/data/parser/classdeclaration.dupetransactionname.cto'); | ||
(() => { | ||
asset.validate(); | ||
}).should.throw(/Duplicate class/); | ||
}); | ||
|
||
it('should throw when participant name is duplicted in a modelfile', () => { | ||
let asset = introspectUtils.loadModelFile('test/data/parser/classdeclaration.dupeparticipantname.cto'); | ||
(() => { | ||
asset.validate(); | ||
}).should.throw(/Duplicate class/); | ||
}); | ||
|
||
it('should throw when concept name is duplicted in a modelfile', () => { | ||
let asset = introspectUtils.loadModelFile('test/data/parser/classdeclaration.dupeconceptname.cto'); | ||
(() => { | ||
asset.validate(); | ||
}).should.throw(/Duplicate class/); | ||
}); | ||
|
||
it('should throw when enum name is duplicted in a modelfile', () => { | ||
let asset = introspectUtils.loadModelFile('test/data/parser/classdeclaration.dupeenumname.cto'); | ||
(() => { | ||
asset.validate(); | ||
}).should.throw(/Duplicate class/); | ||
}); | ||
|
||
it('should throw if an import exists for an invalid namespace', () => { | ||
const model = ` | ||
namespace [email protected] | ||
|