github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/command/plugins_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package command 5 6 import ( 7 "os" 8 "reflect" 9 "testing" 10 ) 11 12 func TestPluginPath(t *testing.T) { 13 td := testTempDir(t) 14 defer os.RemoveAll(td) 15 defer testChdir(t, td)() 16 17 pluginPath := []string{"a", "b", "c"} 18 19 m := Meta{} 20 if err := m.storePluginPath(pluginPath); err != nil { 21 t.Fatal(err) 22 } 23 24 restoredPath, err := m.loadPluginPath() 25 if err != nil { 26 t.Fatal(err) 27 } 28 29 if !reflect.DeepEqual(pluginPath, restoredPath) { 30 t.Fatalf("expected plugin path %#v, got %#v", pluginPath, restoredPath) 31 } 32 } 33 34 func TestInternalProviders(t *testing.T) { 35 m := Meta{} 36 internal := m.internalProviders() 37 tfProvider, err := internal["terraform"]() 38 if err != nil { 39 t.Fatal(err) 40 } 41 42 schema := tfProvider.GetProviderSchema() 43 _, found := schema.DataSources["terraform_remote_state"] 44 if !found { 45 t.Errorf("didn't find terraform_remote_state in internal \"terraform\" provider") 46 } 47 }