Skip to content

Commit fdb7f1d

Browse files
committed
chore: always cleanup before testing
moving the initial cleanup to the setup file instead of calling it at the beginning of an integration test.
1 parent ecb01c3 commit fdb7f1d

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

test/integration/kubernetes.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,10 @@ import * as kubectl from '../helpers/kubectl';
1313

1414
let integrationId: string;
1515

16-
async function tearDown() {
16+
tap.tearDown(async() => {
1717
console.log('Begin removing the snyk-monitor...');
1818
await setup.removeMonitor();
1919
console.log('Removed the snyk-monitor!');
20-
}
21-
22-
tap.tearDown(tearDown);
23-
24-
tap.test('start with clean environment', async () => {
25-
try {
26-
await tearDown();
27-
} catch (error) {
28-
console.log(`could not start with a clean environment: ${error.message}`);
29-
}
3020
});
3121

3222
// Make sure this runs first -- deploying the monitor for the next tests

test/integration/package-manager.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ if (!packageManager) {
1919
throw new Error('Missing PACKAGE_MANAGER environment variable');
2020
}
2121

22-
async function tearDown() {
22+
tap.tearDown(async () => {
2323
console.log('Begin removing the snyk-monitor...');
2424
await removeMonitor();
2525
console.log('Removed the snyk-monitor!');
26-
}
27-
28-
tap.tearDown(tearDown);
26+
});
2927

3028
// Make sure this runs first -- deploying the monitor for the next tests
3129
tap.test('deploy snyk-monitor', async (t) => {

test/setup/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ export async function deployMonitor(): Promise<string> {
135135
await kubectl.downloadKubectl();
136136
if (createCluster) {
137137
await platforms[testPlatform].create();
138+
await platforms[testPlatform].config();
139+
} else {
140+
await platforms[testPlatform].config();
141+
await platforms[testPlatform].clean();
138142
}
139143
const remoteImageName = await platforms[testPlatform].loadImage(imageNameAndTag);
140-
await platforms[testPlatform].config();
141144
await createEnvironment();
142145
await createSecretForGcrIoAccess();
143146

0 commit comments

Comments
 (0)