Skip to content

Commit

Permalink
chore: improve test space deletion (#1480)
Browse files Browse the repository at this point in the history
* chore: improve test space deletion
  • Loading branch information
damienxy authored Sep 13, 2022
1 parent d0b3bf6 commit a3b4bc5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,5 @@ export const generateRandomId = (prefix = 'randomId') => {
}

export const cleanupTestSpaces = async (dryRun = false) => {
return testUtils.cleanUpTestSpaces({ threshold: 60 * 60 * 1000, dryRun })
return testUtils.cleanUpTestSpaces({ threshold: 10 * 60 * 1000, dryRun })
}
6 changes: 6 additions & 0 deletions test/integration/release-action-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ describe('ReleaseAction Api', async () => {
testReleaseAction2 = await testRelease2.validate()
})

after(async () => {
if (testSpace) {
return testSpace.delete()
}
})

describe('Read', () => {
test('Get ReleaseAction', async () => {
const releaseAction = await testEnvironment.getReleaseAction({
Expand Down
6 changes: 6 additions & 0 deletions test/integration/release-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe('Release Api', async function () {
}
})

after(async () => {
if (testSpace) {
return testSpace.delete()
}
})

describe('Read', () => {
test('Get Release', async () => {
const createdRelease = await testEnvironment.createRelease({
Expand Down
21 changes: 17 additions & 4 deletions test/mocha-global.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { after } from 'mocha'
import { before, after } from 'mocha'
import { cleanupTestSpaces } from './helpers'

after('clean up test spaces', async () => {
const housekeeping = async () => {
try {
await cleanupTestSpaces()
} catch {
// ignore if the cleanup fails. Usually fails locally due to missing credentials
} catch (err) {
if (err.message === 'Missing credential') {
console.log('Skipped deletion of old test spaces due to missing credentials.')
} else {
console.log('Skipped deletion of old test spaces. Error:', err.message)
}
}
}

before('clean up test spaces', async () => {
await housekeeping()
console.log('Running tests...')
})

after('clean up test spaces', async () => {
await housekeeping()
})

0 comments on commit a3b4bc5

Please sign in to comment.