2023-05-02 10:33:06 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-05-04 13:03:57 -05:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-06-15 14:23:16 -05:00
|
|
|
"reflect"
|
|
|
|
"testing"
|
2017-05-04 13:03:57 -05:00
|
|
|
)
|
|
|
|
|
2017-06-15 14:23:16 -05:00
|
|
|
func TestPluginPath(t *testing.T) {
|
2018-03-28 12:08:38 -05:00
|
|
|
td := testTempDir(t)
|
2020-01-13 14:10:00 -06:00
|
|
|
defer os.RemoveAll(td)
|
2017-06-15 14:23:16 -05: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 13:36:31 -05:00
|
|
|
func TestInternalProviders(t *testing.T) {
|
|
|
|
m := Meta{}
|
|
|
|
internal := m.internalProviders()
|
2020-03-31 16:02:40 -05:00
|
|
|
tfProvider, err := internal["terraform"]()
|
2017-11-03 13:36:31 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-02-18 09:13:43 -06:00
|
|
|
schema := tfProvider.GetProviderSchema()
|
2018-09-30 10:06:31 -05:00
|
|
|
_, found := schema.DataSources["terraform_remote_state"]
|
2017-11-03 13:36:31 -05:00
|
|
|
if !found {
|
|
|
|
t.Errorf("didn't find terraform_remote_state in internal \"terraform\" provider")
|
|
|
|
}
|
|
|
|
}
|