(t *testing.T)
| 17 | var _ hcl.Body = deepWrapper{} |
| 18 | |
| 19 | func TestDeep(t *testing.T) { |
| 20 | |
| 21 | testTransform := TransformerFunc(func(body hcl.Body) hcl.Body { |
| 22 | _, remain, diags := body.PartialContent(&hcl.BodySchema{ |
| 23 | Blocks: []hcl.BlockHeaderSchema{ |
| 24 | { |
| 25 | Type: "remove", |
| 26 | }, |
| 27 | }, |
| 28 | }) |
| 29 | |
| 30 | return BodyWithDiagnostics(remain, diags) |
| 31 | }) |
| 32 | |
| 33 | src := hcltest.MockBody(&hcl.BodyContent{ |
| 34 | Attributes: hcltest.MockAttrs(map[string]hcl.Expression{ |
| 35 | "true": hcltest.MockExprLiteral(cty.True), |
| 36 | }), |
| 37 | Blocks: []*hcl.Block{ |
| 38 | { |
| 39 | Type: "remove", |
| 40 | Body: hcl.EmptyBody(), |
| 41 | }, |
| 42 | { |
| 43 | Type: "child", |
| 44 | Body: hcltest.MockBody(&hcl.BodyContent{ |
| 45 | Blocks: []*hcl.Block{ |
| 46 | { |
| 47 | Type: "remove", |
| 48 | }, |
| 49 | }, |
| 50 | }), |
| 51 | }, |
| 52 | }, |
| 53 | }) |
| 54 | |
| 55 | wrapped := Deep(src, testTransform) |
| 56 | |
| 57 | rootContent, diags := wrapped.Content(&hcl.BodySchema{ |
| 58 | Attributes: []hcl.AttributeSchema{ |
| 59 | { |
| 60 | Name: "true", |
| 61 | }, |
| 62 | }, |
| 63 | Blocks: []hcl.BlockHeaderSchema{ |
| 64 | { |
| 65 | Type: "child", |
| 66 | }, |
| 67 | }, |
| 68 | }) |
| 69 | if len(diags) != 0 { |
| 70 | t.Errorf("unexpected diagnostics for root content") |
| 71 | for _, diag := range diags { |
| 72 | t.Logf("- %s", diag) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | wantAttrs := hcltest.MockAttrs(map[string]hcl.Expression{ |
nothing calls this directly
no test coverage detected