Skip to content

test(magician): refactor test-terraform-vcr to use testing sandbox#17956

Draft
majedalfaraj wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
majedalfaraj:refactor-test-terraform-vcr
Draft

test(magician): refactor test-terraform-vcr to use testing sandbox#17956
majedalfaraj wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
majedalfaraj:refactor-test-terraform-vcr

Conversation

@majedalfaraj

Copy link
Copy Markdown
Contributor

Migrates test_terraform_vcr_test.go to replace mockRunner with the sandbox testing framework. To support the use of the physical filesys, test_terraform_vcr.go was updated to dynamically resolve diff_comment_id.txt's path using the new WORKSPACE env variable (defaulting to /workspace). This preserves behaviour in production, while allowing local testing in a temporary directory.


Migrates `test_terraform_vcr_test.go` to replace `mockRunner` with the sandbox testing framework. To support the use of the physical filesys, `test_terraform_vcr.go` was updated to dynamically resolve `diff_comment_id.txt`'s path using the new `WORKSPACE` env variable (defaulting to `/workspace`). This preserves behaviour in production, while allowing local testing in a temporary directory.
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 12, 2026
@github-actions

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@github-actions github-actions Bot requested a review from slevenick June 12, 2026 18:54
@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 12, 2026
@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 89076f4:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

},
}
sb := newSandbox(t)
os.Setenv("WORKSPACE", sb.Dir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't love setting env vars in a test. Can we do this another way, like by passing the workspace into the runner/sandbox at some point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I changed the functions and method signatures to include a workspace argument instead. Instead of adding new fields to the sandbox (which would impact the other active PRs), I updated this test's helper functions to include an extra workspace parameter. This allows the test to pass the sandbox's directory to the helpers for local testing, while the production code passes /workspace instead.

@majedalfaraj majedalfaraj marked this pull request as draft June 12, 2026 22:45
…erraform-vcr

Update `test_terraform_vcr.go` to accept the workspace directory as a new function argument instead of creating and reading from the OS environment variables. Allows the tests to pass `sb.Dir` for local tests whilst passing `/workspace` for the default prod behaviour.
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 12, 2026
@majedalfaraj majedalfaraj marked this pull request as ready for review June 12, 2026 23:14
@github-actions github-actions Bot requested a review from slevenick June 12, 2026 23:15
@github-actions

Copy link
Copy Markdown

@slevenick This PR is approved and has been waiting for merge for 1 week. Is it ready to merge? Use the label disable-review-reminders to disable these notifications.

@majedalfaraj majedalfaraj marked this pull request as draft June 28, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants