mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
52a1b22f7a
This is a refactored version of the `remote` backend that was initially added to Terraform v0.11.8 which should now be compatible with v0.12.0.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package atlas
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
"github.com/hashicorp/terraform/backend"
|
|
)
|
|
|
|
func TestImpl(t *testing.T) {
|
|
var _ backend.Backend = new(Backend)
|
|
var _ backend.CLI = new(Backend)
|
|
}
|
|
|
|
func TestConfigure_envAddr(t *testing.T) {
|
|
defer os.Setenv("ATLAS_ADDRESS", os.Getenv("ATLAS_ADDRESS"))
|
|
os.Setenv("ATLAS_ADDRESS", "http://foo.com")
|
|
|
|
b := New()
|
|
diags := b.Configure(cty.ObjectVal(map[string]cty.Value{
|
|
"name": cty.StringVal("foo/bar"),
|
|
"address": cty.NullVal(cty.String),
|
|
"access_token": cty.StringVal("placeholder"),
|
|
}))
|
|
for _, diag := range diags {
|
|
t.Error(diag)
|
|
}
|
|
|
|
if got, want := b.stateClient.Server, "http://foo.com"; got != want {
|
|
t.Fatalf("wrong URL %#v; want %#v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestConfigure_envToken(t *testing.T) {
|
|
defer os.Setenv("ATLAS_TOKEN", os.Getenv("ATLAS_TOKEN"))
|
|
os.Setenv("ATLAS_TOKEN", "foo")
|
|
|
|
b := New()
|
|
diags := b.Configure(cty.ObjectVal(map[string]cty.Value{
|
|
"name": cty.StringVal("foo/bar"),
|
|
"address": cty.NullVal(cty.String),
|
|
"access_token": cty.NullVal(cty.String),
|
|
}))
|
|
for _, diag := range diags {
|
|
t.Error(diag)
|
|
}
|
|
|
|
if got, want := b.stateClient.AccessToken, "foo"; got != want {
|
|
t.Fatalf("wrong access token %#v; want %#v", got, want)
|
|
}
|
|
}
|