@@ -246,7 +246,10 @@ func TestInitProviders_pluginCache(t *testing.T) {
246246 }
247247
248248 cmd := tf .Cmd ("init" )
249- cmd .Env = append (cmd .Env , "TF_PLUGIN_CACHE_DIR=./cache" )
249+
250+ // convert the slashes if building for windows.
251+ p := filepath .FromSlash ("./cache" )
252+ cmd .Env = append (cmd .Env , "TF_PLUGIN_CACHE_DIR=" + p )
250253 cmd .Stdin = nil
251254 cmd .Stderr = & bytes.Buffer {}
252255
@@ -260,7 +263,7 @@ func TestInitProviders_pluginCache(t *testing.T) {
260263 t .Errorf ("unexpected stderr output:\n %s\n " , stderr )
261264 }
262265
263- path := fmt .Sprintf (".terraform/plugins/registry.terraform.io/hashicorp/template/2.1.0/%s_%s/terraform-provider-template_v2.1.0_x4" , runtime .GOOS , runtime .GOARCH )
266+ path := filepath . FromSlash ( fmt .Sprintf (".terraform/plugins/registry.terraform.io/hashicorp/template/2.1.0/%s_%s/terraform-provider-template_v2.1.0_x4" , runtime .GOOS , runtime .GOARCH ) )
264267 content , err := tf .ReadFile (path )
265268 if err != nil {
266269 t .Fatalf ("failed to read installed plugin from %s: %s" , path , err )
@@ -269,12 +272,20 @@ func TestInitProviders_pluginCache(t *testing.T) {
269272 t .Errorf ("template plugin was not installed from local cache" )
270273 }
271274
272- if ! tf .FileExists (fmt .Sprintf (".terraform/plugins/registry.terraform.io/hashicorp/null/2.1.0/%s_%s/terraform-provider-null_v2.1.0_x4" , runtime .GOOS , runtime .GOARCH )) {
273- t .Errorf ("null plugin was not installed" )
275+ nullLinkPath := filepath .FromSlash (fmt .Sprintf (".terraform/plugins/registry.terraform.io/hashicorp/null/2.1.0/%s_%s/terraform-provider-null_v2.1.0_x4" , runtime .GOOS , runtime .GOARCH ))
276+ if runtime .GOOS == "windows" {
277+ nullLinkPath = nullLinkPath + ".exe"
278+ }
279+ if ! tf .FileExists (nullLinkPath ) {
280+ t .Errorf ("null plugin was not installed into %s" , nullLinkPath )
274281 }
275282
276- if ! tf .FileExists (fmt .Sprintf ("cache/registry.terraform.io/hashicorp/null/2.1.0/%s_%s/terraform-provider-null_v2.1.0_x4" , runtime .GOOS , runtime .GOARCH )) {
277- t .Errorf ("null plugin is not in cache after install" )
283+ nullCachePath := filepath .FromSlash (fmt .Sprintf ("cache/registry.terraform.io/hashicorp/null/2.1.0/%s_%s/terraform-provider-null_v2.1.0_x4" , runtime .GOOS , runtime .GOARCH ))
284+ if runtime .GOOS == "windows" {
285+ nullCachePath = nullCachePath + ".exe"
286+ }
287+ if ! tf .FileExists (nullCachePath ) {
288+ t .Errorf ("null plugin is not in cache after install. expected in: %s" , nullCachePath )
278289 }
279290}
280291
0 commit comments