github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/plugins_test.go (about)

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