2017-02-22 07:13:46 +01:00
|
|
|
package atlas
|
|
|
|
|
|
|
|
import (
|
2017-03-17 07:03:11 +01:00
|
|
|
"os"
|
2017-02-22 07:13:46 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/backend"
|
2017-03-17 07:03:11 +01:00
|
|
|
"github.com/hashicorp/terraform/config"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2017-02-22 07:13:46 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestImpl(t *testing.T) {
|
|
|
|
var _ backend.Backend = new(Backend)
|
2017-02-28 23:38:24 +01:00
|
|
|
var _ backend.CLI = new(Backend)
|
2017-02-22 07:13:46 +01:00
|
|
|
}
|
2017-03-17 07:03:11 +01:00
|
|
|
|
|
|
|
func TestConfigure_envAddr(t *testing.T) {
|
|
|
|
defer os.Setenv("ATLAS_ADDRESS", os.Getenv("ATLAS_ADDRESS"))
|
|
|
|
os.Setenv("ATLAS_ADDRESS", "http://foo.com")
|
|
|
|
|
|
|
|
b := &Backend{}
|
|
|
|
err := b.Configure(terraform.NewResourceConfig(config.TestRawConfig(t, map[string]interface{}{
|
|
|
|
"name": "foo/bar",
|
|
|
|
})))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if b.stateClient.Server != "http://foo.com" {
|
|
|
|
t.Fatalf("bad: %#v", b.stateClient)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfigure_envToken(t *testing.T) {
|
|
|
|
defer os.Setenv("ATLAS_TOKEN", os.Getenv("ATLAS_TOKEN"))
|
|
|
|
os.Setenv("ATLAS_TOKEN", "foo")
|
|
|
|
|
|
|
|
b := &Backend{}
|
|
|
|
err := b.Configure(terraform.NewResourceConfig(config.TestRawConfig(t, map[string]interface{}{
|
|
|
|
"name": "foo/bar",
|
|
|
|
})))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if b.stateClient.AccessToken != "foo" {
|
|
|
|
t.Fatalf("bad: %#v", b.stateClient)
|
|
|
|
}
|
|
|
|
}
|