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:
Martin Atkins 2018-10-02 15:12:06 -07:00
parent 8565c7460e
commit 1c007473ba
1 changed files with 7 additions and 0 deletions

View File

@ -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)