terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Add acceptance and internal tests for `gcs` backend, add some test helper functions

Open SarahFrench opened this issue 1 year ago • 1 comments

Historically the gcs backend hasn't been touched much. In the past I've added a few features but largely left the existing codebase as it was previously. Recently the gcs backend was refactored in https://github.com/hashicorp/terraform/pull/34989 to avoid using the old SDK.

As part of reviewing that PR I started adding a few acceptance tests in this PR. There's a lot more work to be done but I want to avoid this PR getting too big.

This PR:

  • Separates acceptance tests and 'internal' tests into separate _test.go files
  • Implements some pre-check functions to test for TF_ACC being set and credentials being supplied by the test environment
    • When this info is missing the tests are skipped, to enable checks passing in this repo. This repo has no automated testing of the gcs backend set up (//TODO!)
  • Adds internal tests that assert:
    • TestBackendConfig_encryptionKey - how the config and ENVs for customer-supplied encryption keys are used
    • TestBackendConfig_kmsKey - how the config and ENVs for customer-managed (KMS) encryption keys are used
  • Adds acc tests the assert:
    • TestAccBackendConfig_credentials - empty strings in the backend config don't interrupt use of ENVs for creds.
    • Note: we cannot have tests where we assert a failure, due to legacy reasons.

Target Release

1.8.x

Draft CHANGELOG entry

NEW FEATURES | UPGRADE NOTES | ENHANCEMENTS | BUG FIXES | EXPERIMENTS

SarahFrench avatar Apr 18 '24 22:04 SarahFrench

Just rebased to include the latest gcs PR

SarahFrench avatar Apr 25 '24 20:04 SarahFrench

Tests pass when I run them with TF_ACC=1 locally, merging. Thanks for the review John!

SarahFrench avatar Jul 12 '24 16:07 SarahFrench

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

github-actions[bot] avatar Jul 12 '24 16:07 github-actions[bot]

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Aug 12 '24 02:08 github-actions[bot]