falco
falco copied to clipboard
[Feature] Structure unit-tests like a jest to illustrate VCL's workflow
Kind of proposals
You can turn on multiple checkboxes.
- [] Parser
- [] Linter
- [] Simulator
- [x] Testing
Describe the feature
Thank you for developing this great tool! This is just a feature request about falco's testing feature.
I want the function to structure unit-tests like a jest's describe, test, it
label. Due to the VCL's variable limitation, VCL's each subroutine's set it's returned value as a global variable(like a req.http.VARS:hoge
), and a following subroutine will refers it and invoke the process which depends on it (at least in my application).
In a view of testing, each unit-test set req.http.VARS:~~
as parameters before invoking a testing targeted subroutine, and invoke subroutine, and asseret req.http.VARS:~~
as it's returned values. This way is useful for testing in a micro-scope, but not useful for in a macro-scope.
I want the function to structure (or unify) micro-scope unit-tests ( it
) and illustrate macro-scope testing scenario (describe
)
usecase in real world
for example, please think about writing a VCL to handle login processing. You might want to split the its processing to the above 3 steps (= subroutine ).
- parse auth JWT in cookie:
sub parse_jwt
- Validate the result of parsed JWT in step 1:
sub validate_jwt
- Handle the specific process for the each auth state.:
sub handle_auth
As mentioned above, each unit-tests for the each subroutine set some req.http.VARS:~~
as parameters, and assert req.http.VARS:~~
as subroutine's returned value.
Each unit-test's meaning and subroutine's specification are clear thanks to it's label setted by @suite
decorator, but overall login flow's test's meaning and specification are unclear in a macro view.