(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestDecodeBody(t *testing.T) { |
| 20 | deepEquals := func(other interface{}) func(v interface{}) bool { |
| 21 | return func(v interface{}) bool { |
| 22 | return reflect.DeepEqual(v, other) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | type withNameExpression struct { |
| 27 | Name hcl.Expression `hcl:"name"` |
| 28 | } |
| 29 | |
| 30 | type withTwoAttributes struct { |
| 31 | A string `hcl:"a,optional"` |
| 32 | B string `hcl:"b,optional"` |
| 33 | } |
| 34 | |
| 35 | type withNestedBlock struct { |
| 36 | Plain string `hcl:"plain,optional"` |
| 37 | Nested *withTwoAttributes `hcl:"nested,block"` |
| 38 | } |
| 39 | |
| 40 | type withListofNestedBlocks struct { |
| 41 | Nested []*withTwoAttributes `hcl:"nested,block"` |
| 42 | } |
| 43 | |
| 44 | type withListofNestedBlocksNoPointers struct { |
| 45 | Nested []withTwoAttributes `hcl:"nested,block"` |
| 46 | } |
| 47 | |
| 48 | tests := []struct { |
| 49 | Body map[string]interface{} |
| 50 | Target func() interface{} |
| 51 | Check func(v interface{}) bool |
| 52 | DiagCount int |
| 53 | }{ |
| 54 | { |
| 55 | map[string]interface{}{}, |
| 56 | makeInstantiateType(struct{}{}), |
| 57 | deepEquals(struct{}{}), |
| 58 | 0, |
| 59 | }, |
| 60 | { |
| 61 | map[string]interface{}{}, |
| 62 | makeInstantiateType(struct { |
| 63 | Name string `hcl:"name"` |
| 64 | }{}), |
| 65 | deepEquals(struct { |
| 66 | Name string `hcl:"name"` |
| 67 | }{}), |
| 68 | 1, // name is required |
| 69 | }, |
| 70 | { |
| 71 | map[string]interface{}{}, |
| 72 | makeInstantiateType(struct { |
| 73 | Name *string `hcl:"name"` |
| 74 | }{}), |
| 75 | deepEquals(struct { |
| 76 | Name *string `hcl:"name"` |
nothing calls this directly
no test coverage detected