Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

feat!: add clean up test environments #25

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

crissto
Copy link
Contributor

@crissto crissto commented Oct 26, 2022

Hello!
I'm doing this PR because when I did the integration testing for a project I didn't take into account that sometimes environments get too long to get created and my tests timeout so now we have some environments that should be deleted.
Instead of adding it as a script in the tests I thought it would be useful for future contentful users to add it to this package.

I also updated some dependencies as dependabot doesn't seem to update them? I can remove that commit if we want to stick to the previous versions.

@crissto crissto requested a review from damienxy October 26, 2022 07:23
@crissto crissto self-assigned this Oct 26, 2022
@marcolink
Copy link
Member

Sorry - what I meant is:

testUtils.cleanUp()

This should clean up all things created during that test run.

Test Environments
They also need some sort of prefix - it could be the case that we want to delete test environments on a specific space.

@crissto
Copy link
Contributor Author

crissto commented Oct 26, 2022

Sorry - what I meant is:

testUtils.cleanUp()

This should clean up all things created during that test run.

Test Environments They also need some sort of prefix - it could be the case that we want to delete test environments on a specific space.

Umm I will also add that 👍

I thought about adding a prefix to test environment deletion but decided to go for the regex. If I suppose a prefix I could break someones tests. I guess I could add it by default on env creation also so it is consistent

BREAKING CHANGE: Updated node and packages versions, switched to plainClient, changed params for functions
@@ -50,12 +50,29 @@ const testSpace = await testUtils.createTestSpace({

#### Create Test Environment
Creates a test environment in the provided space and waits for it to be ready (timeout: 5 minutes).
The length of the environment name must be less than 40 characters.
The length of the environment name must be less than 40 characters and the environment will have prefixed a `%`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The length of the environment name must be less than 40 characters and the environment will have prefixed a `%`
The length of the environment name must be less than 40 characters and the environment name will have prefixed a `%`

src/clean-up.ts Outdated
export async function cleanUp(options: CleanUpSpacesOptions) {
const client = options.client ?? initClient();
for (const space of options.spaces) {
await cleanUpTestEnvironments({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe first cleanup all test spaces, and then all test environments on the spaces that are still around? 🤔

Copy link
Member

@marcolink marcolink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ready to be released 🎉
Make sure you set the right commit message to force a new major version.

@damienxy any comments from your side?

@crissto crissto changed the title feat: add clean up test environments feat!: add clean up test environments Feb 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants