MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestCompose

Function TestCompose

policy/composer_test.go:15–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func 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
28rule:
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
39rule:
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
52rule:
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
64rule:
65 match:
66 - condition: "2 == 2"
67 rule:
68 match:
69 - condition: "1 == 1"
70 output: "'foo'"
71 - condition: "true"
72 rule:

Callers

nothing calls this directly

Calls 15

NewExtensionVersionFunction · 0.92
ToDebugStringWithIDsFunction · 0.92
AstToStringFunction · 0.92
NoVarsFunction · 0.92
ExpressionUnnestHeightFunction · 0.85
parseAndComposeRuleFunction · 0.85
verifySourceInfoTransferFunction · 0.85
HasExtensionMethod · 0.80
NativeRepMethod · 0.80
OffsetRangesMethod · 0.80
ProgramMethod · 0.80
normalizeFunction · 0.70

Tested by

no test coverage detected