Relay CLI allows creating a test cases for your functions
Relay CLI implements a test command:
relay function test -f spec.yaml
that can run a test. Example spec file:
version:"v1"filename:spec_func.lua# Location of the function filedriver:luatests: - name:standard request# Test case (you can define multiple test cases)request:method:PUTbody:| { "user": "john" }header:foo:barexpect:request:bodyModified:truebodyContains:"some"bodyEquals:"something new"# HeaderheaderModified:true# Method checkmethodEquals:POSTresponse:bodyContains:"hello"
version:"v1"filename:spec_func.lua# Location of the function filedriver:luatests: - name:standard request# Test case (you can define multiple test cases)request:method:PUTbody:| { "user": "john" }header:foo:barexpect:request:modified:true# Is true when any of the fields get modified# Body checksbodyModified:truebodyContains:"some"bodyEquals:"something new"# HeaderheaderModified:trueheaderEquals:Authorization:"Bearer xyz"# Method checkmethodModified:truemethodEquals:POST# Request path checkspathModified:falsepathEquals:/some/pathpathContains:/users# Query args (e.g. ?foo=bar)queryModified:truequeryContains:foo=barresponse:bodyContains:"hello"