backend/terraform: additional test coverage for error cases in getBackend
This commit is contained in:
parent
81b8891b90
commit
db1a623ed4
|
@ -1,11 +1,11 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
"testing"
|
||||
|
||||
"github.com/apparentlymart/go-dump/dump"
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
|
@ -41,6 +41,26 @@ func TestState_basic(t *testing.T) {
|
|||
}),
|
||||
false,
|
||||
},
|
||||
"_local": {
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"backend": cty.StringVal("_local"),
|
||||
"config": cty.ObjectVal(map[string]cty.Value{
|
||||
"path": cty.StringVal("./testdata/basic.tfstate"),
|
||||
}),
|
||||
}),
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"backend": cty.StringVal("_local"),
|
||||
"config": cty.ObjectVal(map[string]cty.Value{
|
||||
"path": cty.StringVal("./testdata/basic.tfstate"),
|
||||
}),
|
||||
"outputs": cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"workspace": cty.StringVal(backend.DefaultStateName),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
"complex outputs": {
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"backend": cty.StringVal("local"),
|
||||
|
@ -213,6 +233,24 @@ func TestState_basic(t *testing.T) {
|
|||
}),
|
||||
false,
|
||||
},
|
||||
"nonexistent backend": {
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"backend": cty.StringVal("nonexistent"),
|
||||
"config": cty.ObjectVal(map[string]cty.Value{
|
||||
"path": cty.StringVal("./testdata/basic.tfstate"),
|
||||
}),
|
||||
}),
|
||||
cty.NilVal,
|
||||
true,
|
||||
},
|
||||
"null config": {
|
||||
cty.ObjectVal(map[string]cty.Value{
|
||||
"backend": cty.StringVal("local"),
|
||||
"config": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
cty.NilVal,
|
||||
true,
|
||||
},
|
||||
}
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue