Skip to content

Commit

Permalink
keep trying to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
electrovir committed Sep 12, 2024
1 parent fbed500 commit 1697ff6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/node/src/docker/containers/run-container.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function runMockLongLivingContainer(
'-t',
],
command: 'sh',
platform: 'linux',
platform: 'amd64',
...args,
});
}
6 changes: 3 additions & 3 deletions packages/node/src/docker/containers/run-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe(
detach: false,
imageName: testImageName,
removeWhenDone: true,
platform: 'linux',
platform: 'amd64',
});
await docker.container.waitUntilExited(testContainerName);
});
Expand All @@ -38,7 +38,7 @@ describe(
detach: true,
imageName: testImageName,
removeWhenDone: true,
platform: 'linux',
platform: 'amd64',
});
await docker.container.waitUntilExited(testContainerName);
});
Expand All @@ -53,7 +53,7 @@ describe(
useCurrentUser: true,
removeWhenDone: true,
command: 'random-command-this-does-not-exist-please-electrovir',
platform: 'linux',
platform: 'amd64',
}),
{
matchMessage:
Expand Down
12 changes: 2 additions & 10 deletions packages/node/src/docker/docker-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,9 @@ describe(
it('updates and removes', async () => {
await docker.image.remove(testDockerImageName);
assert.isFalse(await docker.image.exists(testDockerImageName));
await docker.image.update(
testDockerImageName,
/** Use `linux` platform because the test image name does not exist in Windows. */
'linux',
);
await docker.image.update(testDockerImageName, 'amd64');
assert.isTrue(await docker.image.exists(testDockerImageName));
await docker.image.update(
testDockerImageName,
/** Use `linux` platform because the test image name does not exist in Windows. */
'linux',
);
await docker.image.update(testDockerImageName, 'amd64');
});
it('allow missing platform input', async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/docker/docker-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function updateImage(
...(platform
? [
'--platform',
'linux',
platform,
]
: []),
wrapString({value: imageName, wrapper: "'"}),
Expand Down
24 changes: 20 additions & 4 deletions packages/node/src/prisma/prisma-database.mock.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import {rm} from 'node:fs/promises';
import {awaitedForEach} from '@augment-vir/common';
import {interpolationSafeWindowsPath} from '../augments/path/os-path.js';
import {runShellCommand} from '../augments/terminal/shell.js';
import {
generatedPrismaClientDirPath,
notCommittedDirPath,
testPrismaMigrationsDirPath,
} from '../file-paths.mock.js';

const pathsToDelete = [
generatedPrismaClientDirPath,
notCommittedDirPath,
testPrismaMigrationsDirPath,
];

export async function clearTestDatabaseOutputs() {
await rm(generatedPrismaClientDirPath, {force: true, recursive: true});
await rm(notCommittedDirPath, {force: true, recursive: true});
await rm(testPrismaMigrationsDirPath, {force: true, recursive: true});
await awaitedForEach(pathsToDelete, async (pathToDelete) => {
/**
* This way of deleting files is required for Windows tests running on GitHub Actions.
* Otherwise, we get the following error:
*
* EPERM: operation not permitted, unlink 'D:\a\augment-vir\augment-vir\packages\node\node_modules\.prisma\query_engine-windows.dll.node'
*/
await runShellCommand(`sudo rm -rf ${interpolationSafeWindowsPath(pathToDelete)}`, {
rejectOnError: true,
});
});
}

0 comments on commit 1697ff6

Please sign in to comment.