github.com/ergreco76/terraform@v0.11.12-beta1/command/internal_plugin_test.go (about)

     1  package command
     2  
     3  import "testing"
     4  
     5  func TestInternalPlugin_InternalProviders(t *testing.T) {
     6  	m := new(Meta)
     7  	providers := m.internalProviders()
     8  	// terraform is the only provider moved back to internal
     9  	for _, name := range []string{"terraform"} {
    10  		pf, ok := providers[name]
    11  		if !ok {
    12  			t.Errorf("Expected to find %s in InternalProviders", name)
    13  		}
    14  
    15  		provider, err := pf()
    16  		if err != nil {
    17  			t.Fatal(err)
    18  		}
    19  
    20  		if provider == nil {
    21  			t.Fatal("provider factory returned a nil provider")
    22  		}
    23  	}
    24  }
    25  
    26  func TestInternalPlugin_InternalProvisioners(t *testing.T) {
    27  	for _, name := range []string{"chef", "file", "local-exec", "remote-exec", "salt-masterless"} {
    28  		if _, ok := InternalProvisioners[name]; !ok {
    29  			t.Errorf("Expected to find %s in InternalProvisioners", name)
    30  		}
    31  	}
    32  }
    33  
    34  func TestInternalPlugin_BuildPluginCommandString(t *testing.T) {
    35  	actual, err := BuildPluginCommandString("provisioner", "remote-exec")
    36  	if err != nil {
    37  		t.Fatalf(err.Error())
    38  	}
    39  
    40  	expected := "-TFSPACE-internal-plugin-TFSPACE-provisioner-TFSPACE-remote-exec"
    41  	if actual[len(actual)-len(expected):] != expected {
    42  		t.Errorf("Expected command to end with %s; got:\n%s\n", expected, actual)
    43  	}
    44  }