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

fix: Add toUpperCase to provider and region fields in cluster resources #1837

Merged
merged 11 commits into from Jan 16, 2024

Conversation

andreaangiolillo
Copy link
Collaborator

@andreaangiolillo andreaangiolillo commented Jan 15, 2024

Description

Ticket: https://jira.mongodb.org/browse/CLOUDP-222427

This PR adds a validation to the provider_name and region_name fields of the cluster resources to return an error if the user did not provide the uppercase string.

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Testing

I added the unit test TestStringIsUppercase

Running tool: /Users/andrea.angiolillo/.asdf/shims/go test -timeout 300000s -run ^TestStringIsUppercase$ github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster

ok  	github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster	0.776s

@github-actions github-actions bot added the bug label Jan 15, 2024
@andreaangiolillo andreaangiolillo marked this pull request as ready for review January 16, 2024 10:25
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner January 16, 2024 10:25
@andreaangiolillo andreaangiolillo changed the title fix: Add toUpperCase to provider field in cluster resources fix: Add toUpperCase to provider and region fields in cluster resources Jan 16, 2024
@@ -611,3 +613,18 @@ func flattenEndpoints(listEndpoints []matlas.Endpoint) []map[string]any {
}
return endpoints
}

func StringIsUppercase() schema.SchemaValidateDiagFunc {
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks Andrea!
Question: do we really need one more e2e test for this? Why don't we simply unit test this?

My rationale is: the only business logic that we are responsible for is StringIsUppercase; because of that, unit test should suffice. The added value that an e2e can bring here is that we are effectively confirming ValidateDiagFunc method is correctly called.. but that should not be our responsibility and we should trust our framework that will do so.

Happy to discuss more about this (I am thinking this from a "invert the test pyramid" perspective)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I will update the PR. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Copy link
Collaborator

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM

@andreaangiolillo andreaangiolillo merged commit a7dec60 into master Jan 16, 2024
33 checks passed
@andreaangiolillo andreaangiolillo deleted the CLOUDP-222427 branch January 16, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants