Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow create tests with existing ID #799

Merged
merged 6 commits into from
Jun 23, 2022
Merged

Conversation

schoren
Copy link
Contributor

@schoren schoren commented Jun 23, 2022

This PR allows creating tests with existing ID

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@schoren schoren linked an issue Jun 23, 2022 that may be closed by this pull request
@schoren schoren changed the title Allow create tests with Allow create tests with existing ID Jun 23, 2022
Comment on lines +85 to +88
test, exists, err := a.createTestFromDefinition(ctx, definition)
if err != nil {
return runTestOutput{}, fmt.Errorf("could not create test from definition: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of changing how createTestFromDefinition works, why don't you call a.client.ApiApi.GetTest(ctx, id). If it returns an empty test, you create a new one. If not, you call updateTestFromDefinition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this approach is more flexible, because we are not duplicating the logic of verifying if a test exists. If at some point we decide to change that logic to check things besides the ID, this method wouldn't work anymore and we'd need to update both the client and the server

@schoren schoren force-pushed the allow-create-tests-with-id branch from d65c560 to 13d5e3e Compare June 23, 2022 19:06
@schoren schoren merged commit 5ca111d into main Jun 23, 2022
@schoren schoren deleted the allow-create-tests-with-id branch June 23, 2022 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow tests to be created with a predefined ID
2 participants