Tree shaking
Tree shaking for expenses/approval/decision keeps 31 lines, deletes 27 and adds 0. It keeps 2 files and removes 1.
approval_test.rego: 0 lines kept, 27 deleted, 0 added. Tree shaking removes the file.
1# The tests of the policy. They replace `http.send` with `with`, so they do not need the staff directory.
2package expenses.approval_test
3
4import data.expenses.approval
5
6# The response of the staff directory for an employee whose manager is carol.
7carol_manages(_) := {"status_code": 200, "body": {"name": "alice", "manager": "carol"}}
8
9test_manager_approves if {
10 approval.allow with input as {"expense": {"amount": 120, "approver": "carol", "employee": "alice"}}
11 with http.send as carol_manages
12}
13
14test_self_approval_is_denied if {
15 approval.reasons == {"only carol, the manager of alice, can approve"} with input as {"expense": {"amount": 120, "approver": "alice", "employee": "alice"}}
16 with http.send as carol_manages
17}
18
19test_amount_over_the_limit if {
20 "the amount is more than the limit of 1000" in approval.reasons with input as {"expense": {"amount": 5000, "approver": "carol", "employee": "alice"}}
21 with http.send as carol_manages
22}
23
24test_unknown_employee if {
25 approval.reasons == {"the employee is not in the directory"} with input as {"expense": {"amount": 120, "approver": "carol", "employee": "zoe"}}
26 with http.send as {"status_code": 404}
27}
Counts
| Lines kept | 31 |
| Lines deleted | 27 |
| Lines added | 0 |
| Files kept | 2 |
| Files removed | 1 |
Builtins (8)
- concat
- count
- equal
- gt
- http.send
- neq
- sprintf
- yaml.unmarshal
Legend
1A kept line: the shaken bundle has it.
2A deleted line: the shaken bundle does not have it.
+An added line: only the shaken bundle has it.
- policy.rego a removed file