2017-05-04 20:03:57 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-06-15 21:23:16 +02:00
|
|
|
"reflect"
|
|
|
|
"testing"
|
2017-05-04 20:03:57 +02:00
|
|
|
)
|
|
|
|
|
2017-06-15 21:23:16 +02:00
|
|
|
func TestPluginPath(t *testing.T) {
|
2018-03-28 19:08:38 +02:00
|
|
|
td := testTempDir(t)
|
2020-01-13 21:10:00 +01:00
|
|
|
defer os.RemoveAll(td)
|
2017-06-15 21:23:16 +02:00
|
|
|
defer testChdir(t, td)()
|
|
|
|
|
|
|
|
pluginPath := []string{"a", "b", "c"}
|
|
|
|
|
|
|
|
m := Meta{}
|
|
|
|
if err := m.storePluginPath(pluginPath); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
restoredPath, err := m.loadPluginPath()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(pluginPath, restoredPath) {
|
|
|
|
t.Fatalf("expected plugin path %#v, got %#v", pluginPath, restoredPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 19:36:31 +01:00
|
|
|
func TestInternalProviders(t *testing.T) {
|
|
|
|
m := Meta{}
|
|
|
|
internal := m.internalProviders()
|
2020-03-31 23:02:40 +02:00
|
|
|
tfProvider, err := internal["terraform"]()
|
2017-11-03 19:36:31 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-02-18 16:13:43 +01:00
|
|
|
schema := tfProvider.GetProviderSchema()
|
2018-09-30 17:06:31 +02:00
|
|
|
_, found := schema.DataSources["terraform_remote_state"]
|
2017-11-03 19:36:31 +01:00
|
|
|
if !found {
|
|
|
|
t.Errorf("didn't find terraform_remote_state in internal \"terraform\" provider")
|
|
|
|
}
|
|
|
|
}
|