Skip to content
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
4 changes: 2 additions & 2 deletions src/ig/IGExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,8 @@ export class IGExporter {
$1 ? $0.replace($1, `\\${$1}`) : $0
);
const inputIni = ini.parse(inputIniContents);
if (Object.keys(inputIni).length > 1 || inputIni.IG == null) {
logger.error('ig.ini file must contain an [IG] section with no other sections', {
if (inputIni.IG == null) {
logger.error('The ig.ini file must contain an [IG] section.', {
file: inputIniPath
});
}
Expand Down
23 changes: 23 additions & 0 deletions test/ig/IGExporter.ig-ini.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@ describe('IGExporter', () => {
expect(loggerSpy.getAllMessages()).toHaveLength(0);
});

it('should log an error when ig.ini does not have an [IG] section', () => {
const pkg = new Package(minimalConfig);
const igDataPath = path.resolve(__dirname, 'fixtures', 'ig-ini-missing-ig-section');
const exporter = new IGExporter(pkg, null, igDataPath);
exporter.checkIgIni();
const igIniPath = path.join(tempOut, 'ig.ini');
expect(fs.existsSync(igIniPath)).toBeFalsy();
expect(loggerSpy.getAllMessages()).toHaveLength(1);
expect(loggerSpy.getLastMessage('error')).toMatch(
'The ig.ini file must contain an [IG] section.'
);
});

it('should not log an error or warning when ig.ini has additional sections', () => {
const pkg = new Package(minimalConfig);
const igDataPath = path.resolve(__dirname, 'fixtures', 'ig-ini-with-extra-sections');
const exporter = new IGExporter(pkg, null, igDataPath);
exporter.checkIgIni();
const igIniPath = path.join(tempOut, 'ig.ini');
expect(fs.existsSync(igIniPath)).toBeFalsy();
expect(loggerSpy.getAllMessages()).toHaveLength(0);
});

it('should log a warning when ig property in ig.ini does not point to SUSHI IG JSON', () => {
const pkg = new Package(minimalConfig);
const igDataPath = path.resolve(__dirname, 'fixtures', 'ig-ini-with-non-generated-ig');
Expand Down
2 changes: 2 additions & 0 deletions test/ig/fixtures/ig-ini-missing-ig-section/ig.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[DefinitelyNotAnIG]
foo = bar
9 changes: 9 additions & 0 deletions test/ig/fixtures/ig-ini-with-extra-sections/ig.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[SomeSection]
foo = bar

[IG]
ig = fsh-generated/resources/ImplementationGuide-fhir.us.minimal.json
template = hl7.fhir.template#0.1.0

[SomeOtherSection]
bar = bat
Loading