Skip to content

Commit

Permalink
test: parallel nuts to better isolate env
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jul 3, 2024
1 parent fa90725 commit 8d8732b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"test:nuts:local:moved:scale": "mocha \"**/nuts/local/localTrackingFileMovesScale.nut.ts\" --slow 4500 --timeout 600000 --parallel",
"test:nuts:local:moved:image": "mocha \"**/nuts/local/localTrackingFileMovesImage.nut.ts\" --slow 4500 --timeout 600000 --parallel",
"test:nuts:local:moved:child": "mocha \"**/nuts/local/localTrackingFileMovesDecomposedChild.nut.ts\" --slow 4500 --timeout 600000 --parallel",
"test:unit:local:moved": "mocha \"test/unit/localDetectMovedFiles.test.ts\" --slow 4500 --timeout 600000",
"test:unit:local:moved": "mocha \"test/unit/localDetectMovedFiles.test.ts\" --slow 4500 --timeout 600000 --parallel",
"test:only": "wireit"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ describe('can match files with the same hash when the have different parents ',
});
});

afterEach(() => {
delete process.env.SF_BETA_TRACK_FILE_MOVES;
});
after(async () => {
await session?.clean();
});
Expand Down Expand Up @@ -54,9 +57,7 @@ describe('can match files with the same hash when the have different parents ',
});
});

it('should show 0 files (images) in git status after moving them', async () => {
// eslint-disable-next-line no-unused-expressions
expect(process.env.SF_BETA_TRACK_FILE_MOVES).to.be.undefined;
it('should show 0 files in git status after moving them', async () => {
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';
// Commit the existing class files
filesToSync = await repo.getChangedFilenames();
Expand All @@ -79,7 +80,5 @@ describe('can match files with the same hash when the have different parents ',
expect(await repo.getChangedFilenames())
.to.be.an('array')
.with.lengthOf(0);

delete process.env.SF_BETA_TRACK_FILE_MOVES;
});
});
8 changes: 5 additions & 3 deletions test/nuts/local/localTrackingFileMoveThenEdit.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ describe('handles local files moves that also change the file', () => {
after(async () => {
await session?.clean();
});
afterEach(() => {
delete process.env.SF_BETA_TRACK_FILE_MOVES;
});

it('initialize the local tracking', async () => {
expect(typeof process.env.SF_BETA_TRACK_FILE_MOVES).to.equal('undefined');
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';

repo = await ShadowRepo.getInstance({
Expand All @@ -69,6 +71,8 @@ describe('handles local files moves that also change the file', () => {
});

it('move a file and edit it. Only the delete is committed', async () => {
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';

// move all two classes to the new folder
const classFolder = path.join('main', 'default', 'classes');
['OrderController.cls', 'OrderController.cls-meta.xml', 'PagedResult.cls', 'PagedResult.cls-meta.xml'].map((f) =>
Expand All @@ -86,7 +90,5 @@ describe('handles local files moves that also change the file', () => {
expect(await repo.getDeleteFilenames()).to.deep.equal([]);
// this is still considered an "add" because the moved file was changed
expect(await repo.getAddFilenames()).to.deep.equal([editedFilePath]);

delete process.env.SF_BETA_TRACK_FILE_MOVES;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('ignores moved files that are children of a decomposed metadata type',
});

it('should ignore moved child metadata', async () => {
expect(process.env.SF_BETA_TRACK_FILE_MOVES).to.be.undefined;
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';
// Commit the existing files
const filesToSync = await repo.getChangedFilenames();
Expand All @@ -74,6 +73,7 @@ describe('ignores moved files that are children of a decomposed metadata type',
});

it('should clear tracking when the field is moved to another dir', async () => {
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';
const newDir = path.join(session.project.dir, 'force-app', 'other', 'objects', 'Order__c', 'fields');
await fs.promises.mkdir(newDir, {
recursive: true,
Expand Down
7 changes: 4 additions & 3 deletions test/nuts/local/localTrackingFileMovesImage.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ describe('it detects image file moves ', () => {
await session?.clean();
});

afterEach(() => {
delete process.env.SF_BETA_TRACK_FILE_MOVES;
});

it('initialize the local tracking', async () => {
repo = await ShadowRepo.getInstance({
orgId: 'fakeOrgId',
Expand All @@ -45,7 +49,6 @@ describe('it detects image file moves ', () => {
});

it('should show 0 files (images) in git status after moving them', async () => {
expect(process.env.SF_BETA_TRACK_FILE_MOVES).to.be.undefined;
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';
// Commit the existing class files
filesToSync = await repo.getChangedFilenames();
Expand All @@ -65,7 +68,5 @@ describe('it detects image file moves ', () => {
expect(await repo.getChangedFilenames())
.to.be.an('array')
.with.lengthOf(0);

delete process.env.SF_BETA_TRACK_FILE_MOVES;
});
});
6 changes: 4 additions & 2 deletions test/nuts/local/localTrackingFileMovesScale.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ describe(`handles local files moves of ${classCount.toLocaleString()} classes ($
await session?.clean();
});

afterEach(() => {
delete process.env.SF_BETA_TRACK_FILE_MOVES;
});

it('initialize the local tracking', async () => {
repo = await ShadowRepo.getInstance({
orgId: 'fakeOrgId',
Expand All @@ -76,7 +80,6 @@ describe(`handles local files moves of ${classCount.toLocaleString()} classes ($
});

it('should show 0 files in git status after moving them', async () => {
expect(process.env.SF_BETA_TRACK_FILE_MOVES).to.be.undefined;
process.env.SF_BETA_TRACK_FILE_MOVES = 'true';
// Commit the existing class files
filesToSync = await repo.getChangedFilenames();
Expand All @@ -94,6 +97,5 @@ describe(`handles local files moves of ${classCount.toLocaleString()} classes ($
expect(await repo.getChangedFilenames())
.to.be.an('array')
.with.lengthOf(0);
delete process.env.SF_BETA_TRACK_FILE_MOVES;
});
});

0 comments on commit 8d8732b

Please sign in to comment.