-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add simple Organization DataSource and implement integration acceptance tests #8
Conversation
/run-testacc |
/run-testacc |
/testacc |
1 similar comment
/testacc |
/testacc |
/testacc |
/testacc |
/testacc |
.github/workflows/testacc.yml
Outdated
@@ -0,0 +1,67 @@ | |||
# Terraform Provider testing workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these imported from somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they're the ones terraform provide as sample GH action workflows to use for terraform provider repos
), | ||
}, | ||
{ | ||
PreConfig: func() { deleteWorkspaceOutsideOfTerraform(t, workspaceName) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind explaining a bit how these tests work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this to the readme
### Acceptance tests
Acceptance integration tests use a Terraform CLI binary to run real Terraform commands against the Astro API. The goal is to approximate using the provider with Terraform in production as closely as possible.
Using the terraform-plugin-testing framework, each `resource.Test` runs an acceptance test on a resource.
- `ProtoV6ProviderFactories`: map of the provider factories that the test suite will use to create the provider - just has the `astronomer` provider
- `PreCheck`: a function that runs before the test suite starts to check that all the required environment variables are set
- `Steps`: a list of `terraform apply` sequences that the test suite will run. Each step is a `resource.TestStep` that contains a `Config` and `Check` function.
- `Config`: the Terraform configuration that the test will run (ie. the `.tf` file)
- `Check`: function that will verify the state of the resources after the `terraform apply` command has run.
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("astronomer_workspace.test", "name", workspaceName), | ||
resource.TestCheckResourceAttr("astronomer_workspace.test", "description", utils.TestResourceDescription), | ||
testAccCheckWorkspaceExistence(t, workspaceName, true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we expect that once the workspace is deleted, it will be recreated by terraform right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we run terraform apply again then yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so basically this test is doing:
- nuke the workspace from api
- apply terraform
- expect the workspace to be recreated
is this understanding correct? ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea
- nuke workspace via api call (not terraform)
- run
terraform apply
- check that the workspace is recreated with correct properties
resource.TestCheckResourceAttr("astronomer_workspace.test", "cicd_enforced_default", "true"), | ||
), | ||
}, | ||
// IMPORT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this import do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uses the previous step, and imports the resource and checks that the properties are correct
https://stackoverflow.com/questions/68824711/how-can-i-test-terraform-import-in-acceptance-tests
will also add a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some questions only
Description
This PR
testing
framework since thats how the acceptance tests use it and i didnt want to use two testing frameworks🎟 Issue(s)
🧪 Functional Testing
https://github.com/astronomer/astronomer-terraform-provider/actions/runs/8628716132/job/23651443217?pr=8
📸 Screenshots
📋 Checklist
make test
before taking out of draftmake fmt
before taking out of draft