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

feat: acceptance test #153

Merged
merged 8 commits into from
Dec 13, 2023
Merged

feat: acceptance test #153

merged 8 commits into from
Dec 13, 2023

Conversation

joaomper-TE
Copy link
Contributor

@joaomper-TE joaomper-TE commented Dec 12, 2023

This adds acceptance tests and runs against API Team TF Providers account in STG US.

For that effect, its reading the aid and token from some Repository Secrets within the and since this is a public repo, there's a limitation where Pull Request coming from forks are unable to read said secrets. Because of that, we need to create a branch within the repo instead of on ours forks.

@@ -1,69 +1,76 @@
module github.com/thousandeyes/terraform-provider-thousandeyes

go 1.17
go 1.20
Copy link
Contributor Author

Choose a reason for hiding this comment

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

had to upgrade due to some testing logic that needs go 1.20


func New(version string) func() *schema.Provider {
func New() func() *schema.Provider {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused

@@ -70,11 +72,11 @@ func Provider() *schema.Provider {
"thousandeyes_bgp_monitor": dataSourceThousandeyesBGPMonitor(),
"thousandeyes_integration": dataSourceThousandeyesIntegration(),
},
ConfigureFunc: providerConfigure,
ConfigureContextFunc: providerConfigureWithContext,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

taking care of some Deprecation warning

return testAccCheckResourceDestroy(resourceList, state)
},
checkFunc: []resource.TestCheckFunc{
resource.TestCheckResourceAttr(ftpResourceName, "alerts_enabled", "true"),
Copy link
Contributor Author

@joaomper-TE joaomper-TE Dec 12, 2023

Choose a reason for hiding this comment

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

I only scratched the surface here, we can do way more complex validations: https://developer.hashicorp.com/terraform/plugin/sdkv2/testing/acceptance-tests/teststep

For bootstrapping the acceptance tests, this is enough since each tests the following flow:
1- Terraform Plan
2- Terraform Apply
3- New terraform plan to make sure that there are no reported changes
4- Terraform destroy
5- Check, using our testAccCheckDefaultResourceDestroy method that the resources were actually destroyed

@joaomper-TE joaomper-TE marked this pull request as ready for review December 12, 2023 17:15
@joaomper-TE joaomper-TE requested review from pedro-te and a team December 12, 2023 17:15
phpinhei-te
phpinhei-te previously approved these changes Dec 13, 2023
pedro-te
pedro-te previously approved these changes Dec 13, 2023
Copy link
Collaborator

@pedro-te pedro-te left a comment

Choose a reason for hiding this comment

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

This is great, thanks guys!!

@joaomper-TE joaomper-TE dismissed stale reviews from pedro-te and phpinhei-te via 3003b3b December 13, 2023 13:22
@@ -24,7 +24,7 @@ func main() {
opts := &plugin.ServeOpts{
Debug: debugMode,
ProviderAddr: "registry.terraform.io/thousandeyes/thousandeyes",
ProviderFunc: thousandeyes.New(version),
ProviderFunc: thousandeyes.New(),
Copy link
Contributor

Choose a reason for hiding this comment

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

is the global var version still needed?

Copy link
Contributor Author

@joaomper-TE joaomper-TE Dec 13, 2023

Choose a reason for hiding this comment

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

Missed it, thanks!

Don't think so. But upon looking at the comment, it seems that goreleaser did something with the version... not sure how though, since the Provider didn't use the variable 🤔

@joaomper-TE joaomper-TE merged commit 37e93f5 into main Dec 13, 2023
3 checks passed
@joaomper-TE joaomper-TE deleted the feat-acceptance-test branch December 13, 2023 14:49
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.

4 participants