Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Preparation for Go VCR testing#48

Merged
tbroden84 merged 8 commits intomainfrom
go-vcr-testing
Mar 15, 2024
Merged

Preparation for Go VCR testing#48
tbroden84 merged 8 commits intomainfrom
go-vcr-testing

Conversation

@tbroden84
Copy link
Copy Markdown
Contributor

@tbroden84 tbroden84 commented Feb 16, 2024

WHY are these changes introduced?

To use Go-VCR testing package for the provider, the HTTP client transport need to be changeable.

WHAT is this pull request doing?

  • Make HTTP client accessable and to be changed.
  • When polling, change to sleep after an attempt have been triggered.

HOW can this pull request be tested?

Together with provider changes: cloudamqp/terraform-provider-cloudamqp#257

@tbroden84 tbroden84 changed the title WIP: Go vcr testing Preparation for Go VCR testing Mar 13, 2024
@tbroden84 tbroden84 marked this pull request as ready for review March 13, 2024 09:36
Copy link
Copy Markdown
Contributor

@magnushoerberg magnushoerberg left a comment

Choose a reason for hiding this comment

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

Good first step, lets look into merging this into terraform-provider-cloudamqp as next step.

After that we should remove sling and just use the *http.Client directly.

@tbroden84 tbroden84 merged commit 5c6d860 into main Mar 15, 2024
@tbroden84 tbroden84 deleted the go-vcr-testing branch March 15, 2024 12:12
tbroden84 added a commit to cloudamqp/terraform-provider-cloudamqp that referenced this pull request May 2, 2024
### WHY are these changes introduced?

During development to have the confidence to change, update, add new features, improvements and fixes. Cover the provider with tests as much as possible. For this Terraform acceptance test (extension of Go test) can be used. A downside to only relying on acceptance tests, is that all tests require infrastructure resources. Which takes time to create, update and clean up.

With the use of Go VCR, it's possible to record the communication to the API backend and store these as fixtures (cassettes). Then replay these instead of doing the real requests. This will speed up each test significantly.

Requires: 84codes/go-api#48 (merged)

### WHAT is this pull request doing?

- Adapt the Provider to be able to use Go VCR via http client when running acceptance test.
  - Record request/responses to fixtures
  - Replay requests/responses from fixtures
- Append resource configurations.
- Use templated configurations with dynamic values.
- Update Github CI workflow to run all tests on commit.

### HOW can this pull request be tested?

Run tests manually or through automated Github CI workflow.

---------

Co-authored-by: Magnus Hörberg <magnus.hoerberg@gmail.com>
Co-authored-by: Patrik Ragnarsson <patrik@starkast.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants