backend: TestBackendConfig to allow nil config body
This is not normally considered valid, but since this is a test helper we will allow it and just treat it as an empty body.
This commit is contained in:
parent
8565c7460e
commit
1c007473ba
|
@ -27,6 +27,13 @@ func TestBackendConfig(t *testing.T, b Backend, c hcl.Body) Backend {
|
||||||
|
|
||||||
var diags tfdiags.Diagnostics
|
var diags tfdiags.Diagnostics
|
||||||
|
|
||||||
|
// To make things easier for test authors, we'll allow a nil body here
|
||||||
|
// (even though that's not normally valid) and just treat it as an empty
|
||||||
|
// body.
|
||||||
|
if c == nil {
|
||||||
|
c = hcl.EmptyBody()
|
||||||
|
}
|
||||||
|
|
||||||
schema := b.ConfigSchema()
|
schema := b.ConfigSchema()
|
||||||
spec := schema.DecoderSpec()
|
spec := schema.DecoderSpec()
|
||||||
obj, decDiags := hcldec.Decode(c, spec, nil)
|
obj, decDiags := hcldec.Decode(c, spec, nil)
|
||||||
|
|
Loading…
Reference in New Issue