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