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

chore: add foundation for automated Acceptance Testing #71

Merged
merged 10 commits into from
Oct 25, 2023

Conversation

parkedwards
Copy link
Contributor

@parkedwards parkedwards commented Oct 25, 2023

resolves #30
resolves #67

@parkedwards parkedwards requested a review from a team as a code owner October 25, 2023 19:54
Copy link
Contributor

@jimid27 jimid27 left a comment

Choose a reason for hiding this comment

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

lgtm

@parkedwards parkedwards temporarily deployed to Acceptance Tests October 25, 2023 20:07 — with GitHub Actions Inactive
@parkedwards parkedwards temporarily deployed to Acceptance Tests October 25, 2023 20:08 — with GitHub Actions Inactive
)
}

if config.APIKey.IsUnknown() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

duplicated

@parkedwards parkedwards changed the title Chore/acc test foundation chore: add foundation for Acceptance Testing Oct 25, 2023
@parkedwards parkedwards changed the title chore: add foundation for Acceptance Testing chore: add foundation for automated Acceptance Testing Oct 25, 2023
Steps: []resource.TestStep{
{
Config: testutils.ProviderConfig + fixtureAccWorkspaceRoleDataSource(owner),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we actually dont need to re-specify the provider config, there's an implicit, default one that gets loaded. so long as we pass the environment variables, we wont need this one

)
}
// Here, we'll ensure that the /api suffix is present on the endpoint
Copy link
Contributor Author

@parkedwards parkedwards Oct 25, 2023

Choose a reason for hiding this comment

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

this allows the end user to do something like:

provider "prefect" {
  endpoint = "https://api.prefect.cloud"
}

# instead of this, although this would also be accepted

provider "prefect" {
  endpoint = "https://api.prefect.cloud/api"
}

var apiKey string
if !config.APIKey.IsUnknown() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we already perform unknown checks on these config values in the lines above

in this case, we want to do a null check. the unknown values would come into play if we're passing in provider configurations that are dependent on other resource attributes that aren't yet know (like the id of a resource that will be created in the same plan)

if v := os.Getenv(key); v == "" {
t.Fatalf("%s must be set for acceptance tests", key)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we miss these env vars during acceptance testing:

$ TF_ACC=1 make test
gotestsum --max-fails=50 ./...
∅  .
∅  internal/api
∅  internal/client
∅  internal/provider
∅  internal/provider/customtypes
∅  internal/testutils
✖  internal/provider/datasources (273ms)
✖  internal/provider/resources (403ms)

=== Failed
=== FAIL: internal/provider/datasources TestAccDatasource_service_account (0.00s)
    provider.go:34: PREFECT_API_URL must be set for acceptance tests

=== FAIL: internal/provider/datasources TestAccDatasource_workspace_role_defaults (0.00s)
    provider.go:34: PREFECT_API_URL must be set for acceptance tests

=== FAIL: internal/provider/resources TestAccResource_workspace_role (0.00s)
    provider.go:34: PREFECT_API_URL must be set for acceptance tests

@parkedwards parkedwards temporarily deployed to Acceptance Tests October 25, 2023 20:30 — with GitHub Actions Inactive
@parkedwards parkedwards merged commit 7b5b68d into main Oct 25, 2023
5 checks passed
@parkedwards parkedwards deleted the chore/acc-test-foundation branch October 25, 2023 20:34
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.

revisit provider configuration overrides Automated tests for Terraform provider
2 participants