mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix: add Windows stub for CacheTFProviders (#20840)
Fixes https://github.com/coder/internal/issues/1119 ## Description The `CacheTFProviders` function in `testutil/terraform_cache.go` was only available on Linux and macOS due to the `//go:build linux || darwin` build tag. This caused a compile error on Windows when `enterprise/coderd/workspaces_test.go` tried to call it: ``` enterprise\coderd\workspaces_test.go:3403:28: undefined: testutil.CacheTFProviders ``` ## Changes 1. Added `testutil/terraform_cache_windows.go` with a Windows-specific stub implementation that returns an empty string 2. Updated `downloadProviders` helper in `enterprise/coderd/workspaces_test.go` to handle empty paths gracefully ## Behavior - On Linux/macOS: Terraform providers are cached as before - On Windows: Provider caching is skipped, tests download providers normally during `terraform init` ## Testing This should fix the Windows nightly gauntlet failure. The test will still run on Windows, just without provider caching optimization. Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3393,6 +3393,7 @@ func workspaceTagsTerraform(t *testing.T, tc testWorkspaceTagsTerraformCase, dyn
|
|||||||
// This uses the shared testutil caching infrastructure to avoid re-downloading
|
// This uses the shared testutil caching infrastructure to avoid re-downloading
|
||||||
// providers on every test run. It is the responsibility of the caller to set
|
// providers on every test run. It is the responsibility of the caller to set
|
||||||
// TF_CLI_CONFIG_FILE.
|
// TF_CLI_CONFIG_FILE.
|
||||||
|
// On Windows, provider caching is not supported and an empty string is returned.
|
||||||
func downloadProviders(t *testing.T, providersTf string) string {
|
func downloadProviders(t *testing.T, providersTf string) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
@@ -3401,7 +3402,9 @@ func downloadProviders(t *testing.T, providersTf string) string {
|
|||||||
testName := "TestWorkspaceTagsTerraform"
|
testName := "TestWorkspaceTagsTerraform"
|
||||||
|
|
||||||
cliConfigPath := testutil.CacheTFProviders(t, cacheRootDir, testName, templateFiles)
|
cliConfigPath := testutil.CacheTFProviders(t, cacheRootDir, testName, templateFiles)
|
||||||
t.Logf("Set TF_CLI_CONFIG_FILE=%s", cliConfigPath)
|
if cliConfigPath != "" {
|
||||||
|
t.Logf("Set TF_CLI_CONFIG_FILE=%s", cliConfigPath)
|
||||||
|
}
|
||||||
return cliConfigPath
|
return cliConfigPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CacheTFProviders is a no-op on Windows.
|
||||||
|
// Terraform provider caching is only supported on Linux and macOS due to
|
||||||
|
// platform-specific filesystem operations and Terraform's provider mirror behavior.
|
||||||
|
// On Windows, tests will download providers normally during terraform init.
|
||||||
|
func CacheTFProviders(t *testing.T, rootDir string, testName string, templateFiles map[string]string) string {
|
||||||
|
t.Helper()
|
||||||
|
t.Log("Terraform provider caching is not supported on Windows; providers will be downloaded normally")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user