github.com/ctrox/terraform@v0.11.12-beta1/backend/atlas/backend_test.go (about)

     1  package atlas
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/backend"
     8  	"github.com/hashicorp/terraform/config"
     9  	"github.com/hashicorp/terraform/terraform"
    10  )
    11  
    12  func TestImpl(t *testing.T) {
    13  	var _ backend.Backend = new(Backend)
    14  	var _ backend.CLI = new(Backend)
    15  }
    16  
    17  func TestConfigure_envAddr(t *testing.T) {
    18  	defer os.Setenv("ATLAS_ADDRESS", os.Getenv("ATLAS_ADDRESS"))
    19  	os.Setenv("ATLAS_ADDRESS", "http://foo.com")
    20  
    21  	b := New()
    22  	err := b.Configure(terraform.NewResourceConfig(config.TestRawConfig(t, map[string]interface{}{
    23  		"name": "foo/bar",
    24  	})))
    25  	if err != nil {
    26  		t.Fatalf("err: %s", err)
    27  	}
    28  
    29  	if b.stateClient.Server != "http://foo.com" {
    30  		t.Fatalf("bad: %#v", b.stateClient)
    31  	}
    32  }
    33  
    34  func TestConfigure_envToken(t *testing.T) {
    35  	defer os.Setenv("ATLAS_TOKEN", os.Getenv("ATLAS_TOKEN"))
    36  	os.Setenv("ATLAS_TOKEN", "foo")
    37  
    38  	b := New()
    39  	err := b.Configure(terraform.NewResourceConfig(config.TestRawConfig(t, map[string]interface{}{
    40  		"name": "foo/bar",
    41  	})))
    42  	if err != nil {
    43  		t.Fatalf("err: %s", err)
    44  	}
    45  
    46  	if b.stateClient.AccessToken != "foo" {
    47  		t.Fatalf("bad: %#v", b.stateClient)
    48  	}
    49  }