From 1c007473ba09787723e2a1300923fa603eb60f63 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 2 Oct 2018 15:12:06 -0700 Subject: [PATCH] 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. --- backend/testing.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/testing.go b/backend/testing.go index c3da496c3..7fd85c74e 100644 --- a/backend/testing.go +++ b/backend/testing.go @@ -27,6 +27,13 @@ func TestBackendConfig(t *testing.T, b Backend, c hcl.Body) Backend { 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() spec := schema.DecoderSpec() obj, decDiags := hcldec.Decode(c, spec, nil)