github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/backend/atlas/backend_test.go (about) 1 package atlas 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/zclconf/go-cty/cty" 8 9 "github.com/hashicorp/terraform/backend" 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 diags := b.Configure(cty.ObjectVal(map[string]cty.Value{ 23 "name": cty.StringVal("foo/bar"), 24 "address": cty.NullVal(cty.String), 25 "access_token": cty.StringVal("placeholder"), 26 })) 27 for _, diag := range diags { 28 t.Error(diag) 29 } 30 31 if got, want := b.stateClient.Server, "http://foo.com"; got != want { 32 t.Fatalf("wrong URL %#v; want %#v", got, want) 33 } 34 } 35 36 func TestConfigure_envToken(t *testing.T) { 37 defer os.Setenv("ATLAS_TOKEN", os.Getenv("ATLAS_TOKEN")) 38 os.Setenv("ATLAS_TOKEN", "foo") 39 40 b := New() 41 diags := b.Configure(cty.ObjectVal(map[string]cty.Value{ 42 "name": cty.StringVal("foo/bar"), 43 "address": cty.NullVal(cty.String), 44 "access_token": cty.NullVal(cty.String), 45 })) 46 for _, diag := range diags { 47 t.Error(diag) 48 } 49 50 if got, want := b.stateClient.AccessToken, "foo"; got != want { 51 t.Fatalf("wrong access token %#v; want %#v", got, want) 52 } 53 }