-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
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.
lgtm
) | ||
} | ||
|
||
if config.APIKey.IsUnknown() { |
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.
duplicated
Steps: []resource.TestStep{ | ||
{ | ||
Config: testutils.ProviderConfig + fixtureAccWorkspaceRoleDataSource(owner), |
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.
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 |
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.
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() { |
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.
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) | ||
} | ||
} |
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 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
resolves #30
resolves #67