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

Documented how to use field validation functions #10472

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

melinath
Copy link
Member

@melinath melinath commented Apr 17, 2024

Resolved hashicorp/terraform-provider-google#16504

Release Note Template for Downstream PRs (will be copied)


Screenshot 2024-04-17 at 11 10 32 AM Screenshot 2024-04-17 at 11 10 26 AM Screenshot 2024-04-17 at 11 11 27 AM

@melinath melinath requested review from a team, hao-nan-li and NickElliot and removed request for a team and hao-nan-li April 17, 2024 18:16
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.


Unit tests should be added to the appropriate folder in [`magic-modules/mmv1/third_party/terraform/services`](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services) in the file called `resource_PRODUCT_RESOURCE_test.go`. (You may need to create this file if it does not already exist. Replace PRODUCT with the product name and RESOURCE with the resource name; it should match the name of the generated resource file.)

Unit tests should be named like `TestFunctionName` - for example, `TestDiskImageDiffSuppress` tests the `DiskImageDiffSuppress` function.
Copy link
Contributor

@NickElliot NickElliot Apr 17, 2024

Choose a reason for hiding this comment

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

I think it would be useful to link an example here. Not necessarily comprehensively explain every type of unit test, but to illustrate the way tests that seek to verify (expected) error states, or other plan diffs, as we currently lack explanation of these specifics in our documentation for how to make handwritten tests. Or at least add a link to https://developer.hashicorp.com/terraform/plugin/sdkv2/testing/acceptance-tests/teststep which goes into a number of the assertions more specifically.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added an example - let me know what you think! I'm not linking to the acceptance tests doc because these are unit tests rather than acceptance tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Screenshot 2024-04-17 at 2 28 04 PM

@melinath melinath requested a review from NickElliot April 17, 2024 21:29
Copy link
Contributor

@NickElliot NickElliot left a comment

Choose a reason for hiding this comment

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

perfect! lgtm

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@melinath melinath merged commit ac4ac96 into GoogleCloudPlatform:main Apr 17, 2024
10 checks passed
@melinath melinath deleted the tpg-16504 branch April 17, 2024 21:57
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request Apr 19, 2024
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request May 8, 2024
pawelJas pushed a commit to pawelJas/magic-modules that referenced this pull request May 16, 2024
pengq-google pushed a commit to pengq-google/magic-modules that referenced this pull request May 21, 2024
Cheriit pushed a commit to Cheriit/magic-modules that referenced this pull request Jun 4, 2024
pcostell pushed a commit to pcostell/magic-modules that referenced this pull request Jul 16, 2024
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.

Document how to use validation property
3 participants