github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/state/remote/manta_test.go (about)

     1  package remote
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  )
     7  
     8  func TestMantaClient_impl(t *testing.T) {
     9  	var _ Client = new(MantaClient)
    10  }
    11  
    12  func TestMantaClient(t *testing.T) {
    13  	// This test creates an object in Manta in the root directory of
    14  	// the current MANTA_USER.
    15  	//
    16  	// It may incur costs, so it will only run if Manta credential environment
    17  	// variables are present.
    18  
    19  	mantaUser := os.Getenv("MANTA_USER")
    20  	mantaKeyId := os.Getenv("MANTA_KEY_ID")
    21  	mantaUrl := os.Getenv("MANTA_URL")
    22  	mantaKeyMaterial := os.Getenv("MANTA_KEY_MATERIAL")
    23  
    24  	if mantaUser == "" || mantaKeyId == "" || mantaUrl == "" || mantaKeyMaterial == "" {
    25  		t.Skipf("skipping; MANTA_USER, MANTA_KEY_ID, MANTA_URL and MANTA_KEY_MATERIAL must all be set")
    26  	}
    27  
    28  	if _, err := os.Stat(mantaKeyMaterial); err == nil {
    29  		t.Logf("[DEBUG] MANTA_KEY_MATERIAL is a file path %s", mantaKeyMaterial)
    30  	}
    31  
    32  	testPath := "terraform-remote-state-test"
    33  
    34  	client, err := mantaFactory(map[string]string{
    35  		"path":       testPath,
    36  		"objectName": "terraform-test-state.tfstate",
    37  	})
    38  
    39  	if err != nil {
    40  		t.Fatalf("bad: %s", err)
    41  	}
    42  
    43  	mantaClient := client.(*MantaClient)
    44  
    45  	err = mantaClient.Client.PutDirectory(mantaClient.Path)
    46  	if err != nil {
    47  		t.Fatalf("bad: %s", err)
    48  	}
    49  
    50  	defer func() {
    51  		err = mantaClient.Client.DeleteDirectory(mantaClient.Path)
    52  		if err != nil {
    53  			t.Fatalf("bad: %s", err)
    54  		}
    55  	}()
    56  
    57  	testClient(t, client)
    58  }