Skip to content

Commit

Permalink
#1350: replace chai-files > file with await fs.fileRead() to workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed May 29, 2024
1 parent bb41725 commit db9fe27
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 315 deletions.
133 changes: 58 additions & 75 deletions test/general.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import chaiFiles from 'chai-files';
import * as testUtils from './utils.js';
import handler from '../lib/index.js';
chai.use(chaiFiles);
const file = chaiFiles.file;

describe('GENERAL', () => {
beforeEach(() => {
Expand Down Expand Up @@ -343,8 +342,8 @@ describe('GENERAL', () => {
'returned template JSON of retrieveAsTemplate was not equal expected'
);
expect(
file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')));
await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'));

// *** buildDefinition ***
const definitionResult = await handler.buildDefinition(
Expand Down Expand Up @@ -385,8 +384,8 @@ describe('GENERAL', () => {
'returned deployment JSON was not equal expected'
);
expect(
file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')));
await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'));

assert.equal(
testUtils.getAPIHistoryLength() - expectedApiCallsRetrieve,
Expand Down Expand Up @@ -445,8 +444,8 @@ describe('GENERAL', () => {
'returned template JSON of retrieveAsTemplate was not equal expected'
);
expect(
file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')));
await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'));

// *** buildDefinition ***

Expand Down Expand Up @@ -476,8 +475,8 @@ describe('GENERAL', () => {
'returned deployment JSON was not equal expected'
);
expect(
file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')));
await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'));

assert.equal(
testUtils.getAPIHistoryLength() - expectedApiCallsRetrieve,
Expand Down Expand Up @@ -537,8 +536,8 @@ describe('GENERAL', () => {
'returned template JSON of retrieveAsTemplate was not equal expected'
);
expect(
file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')));
await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'));

// *** buildDefinitionBulk ***

Expand Down Expand Up @@ -580,23 +579,19 @@ describe('GENERAL', () => {
// check if files were also created for other BU-market combos
// testBU: testSourceMarket
expect(
file(
testUtils.getActualDeployFile(
'testExisting_automation',
'automation',
'json'
)
await testUtils.getActualDeployFile(
'testExisting_automation',
'automation',
'json'
)
).to.exist;
// _ParentBU_: testTargetMarket
expect(
file(
testUtils.getActualDeployFile(
'testTemplated_automation',
'automation',
'json',
'_ParentBU_'
)
await testUtils.getActualDeployFile(
'testTemplated_automation',
'automation',
'json',
'_ParentBU_'
)
).to.exist;

Expand Down Expand Up @@ -634,34 +629,30 @@ describe('GENERAL', () => {
'returned deployment JSON was not equal expected'
);
expect(
file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')));
await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'));

// check if files were also created for other BU-market combos
// testBU: testSourceMarket
expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'json')))
expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'json'))
.to.exist;
expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'sql'))).to
expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'sql')).to
.exist;
// _ParentBU_: testTargetMarket
expect(
file(
testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'json',
'_ParentBU_'
)
await testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'json',
'_ParentBU_'
)
).to.exist;
expect(
file(
testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'sql',
'_ParentBU_'
)
await testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'sql',
'_ParentBU_'
)
).to.exist;

Expand Down Expand Up @@ -728,8 +719,8 @@ describe('GENERAL', () => {
'returned template JSON of retrieveAsTemplate was not equal expected'
);
expect(
file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')));
await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'));

// *** buildDefinitionBulk chained ***
const definitionResult = await handler.buildDefinitionBulk(
Expand Down Expand Up @@ -780,23 +771,19 @@ describe('GENERAL', () => {
// check if files were also created for other BU-market combos
// testBU: testSourceMarket
expect(
file(
testUtils.getActualDeployFile(
'testExisting_automation',
'automation',
'json'
)
await testUtils.getActualDeployFile(
'testExisting_automation',
'automation',
'json'
)
).to.exist;
// _ParentBU_: testTargetMarket
expect(
file(
testUtils.getActualDeployFile(
'testTemplated_automation',
'automation',
'json',
'_ParentBU_'
)
await testUtils.getActualDeployFile(
'testTemplated_automation',
'automation',
'json',
'_ParentBU_'
)
).to.exist;

Expand Down Expand Up @@ -834,34 +821,30 @@ describe('GENERAL', () => {
'returned deployment JSON was not equal expected'
);
expect(
file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')));
await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'));

// check if files were also created for other BU-market combos
// testBU: testSourceMarket
expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'json')))
expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'json'))
.to.exist;
expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'sql'))).to
expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'sql')).to
.exist;
// _ParentBU_: testTargetMarket
expect(
file(
testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'json',
'_ParentBU_'
)
await testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'json',
'_ParentBU_'
)
).to.exist;
expect(
file(
testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'sql',
'_ParentBU_'
)
await testUtils.getActualDeployFile(
'testTemplated_query',
'query',
'sql',
'_ParentBU_'
)
).to.exist;

Expand Down
26 changes: 11 additions & 15 deletions test/type.asset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('type: asset', () => {
'returned metadata was not equal expected'
);
expect(file(getActualFile('mcdev-issue-1157', 'asset', 'block', 'html'))).to.equal(
file(testUtils.getExpectedFile('9999999', 'asset', 'block-1157-retrieve', 'html'))
await testUtils.getExpectedFile('9999999', 'asset', 'block-1157-retrieve', 'html')
);

assert.deepEqual(
Expand Down Expand Up @@ -335,13 +335,11 @@ describe('type: asset', () => {
'views.html.content'
)
).to.equal(
file(
testUtils.getExpectedFile(
'9999999',
'asset',
'template-templatebasedemail',
'html'
)
await testUtils.getExpectedFile(
'9999999',
'asset',
'template-templatebasedemail',
'html'
)
);
// THEN
Expand Down Expand Up @@ -371,13 +369,11 @@ describe('type: asset', () => {
'views.html.content'
)
).to.equal(
file(
testUtils.getExpectedFile(
'9999999',
'asset',
'build-templatebasedemail',
'html'
)
await testUtils.getExpectedFile(
'9999999',
'asset',
'build-templatebasedemail',
'html'
)
);

Expand Down
Loading

0 comments on commit db9fe27

Please sign in to comment.