(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestCompose(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | policy string |
| 19 | composerOpts []ComposerOption |
| 20 | wantUnparsed string |
| 21 | wantEval string |
| 22 | checkInfo bool |
| 23 | wantBlockExt bool |
| 24 | }{ |
| 25 | { |
| 26 | name: "source_info", |
| 27 | policy: `name: test_policy |
| 28 | rule: |
| 29 | match: |
| 30 | - condition: "2 == 1" |
| 31 | output: "'hi'" |
| 32 | - output: "'hello' + ' world'" |
| 33 | `, |
| 34 | checkInfo: true, |
| 35 | }, |
| 36 | { |
| 37 | name: "unnest", |
| 38 | policy: `name: unnest |
| 39 | rule: |
| 40 | match: |
| 41 | - condition: "2 == 1" |
| 42 | output: "'hi'" |
| 43 | - output: "'hello'" |
| 44 | `, |
| 45 | composerOpts: []ComposerOption{ExpressionUnnestHeight(1)}, |
| 46 | checkInfo: true, |
| 47 | wantBlockExt: true, |
| 48 | }, |
| 49 | { |
| 50 | name: "empty_aggregate", |
| 51 | policy: `name: empty_nested_match_under_aggregate |
| 52 | rule: |
| 53 | aggregate: |
| 54 | - condition: "true" |
| 55 | rule: |
| 56 | match: [] |
| 57 | `, |
| 58 | wantUnparsed: "[]", |
| 59 | wantEval: "[]", |
| 60 | }, |
| 61 | { |
| 62 | name: "conditional_optional_nested", |
| 63 | policy: `name: conditional_optional_nested |
| 64 | rule: |
| 65 | match: |
| 66 | - condition: "2 == 2" |
| 67 | rule: |
| 68 | match: |
| 69 | - condition: "1 == 1" |
| 70 | output: "'foo'" |
| 71 | - condition: "true" |
| 72 | rule: |
nothing calls this directly
no test coverage detected