katt icon indicating copy to clipboard operation
katt copied to clipboard

Erlang code as a step

Open danron opened this issue 8 years ago • 2 comments

Hi.

I needed "smarter" KATT scenarios so I implemented a new step type that I call action. It allows you to write Erlang code as a step and it looks like this, tell me what you think:

Running this in the erlang shell: katt:run("priv/test_action.apib", [{inparam, "invalue"}]).

POST /helloworld
> Accept: text/html
Hello {{<inparam}}
< 200
{
"param1":"{{>param1}}",
"param2":"{{>param2}}"
}

! erlang <<<
A = mymodule:dostuff("{{<param1}}"),
B = othermodule:dostuff("{{<param2}}"),
[{outparam1, A},{outparam2, B}].
>>>

POST {{<outparam1}}/{{<outparam2}}
< 200

danron avatar Feb 08 '17 14:02 danron

Have you seen #53 and specifically this PR https://github.com/for-GET/katt/pull/57 ? I believe this issue should be treated as duplicate, if I'm not mistaken.

andreineculau avatar Mar 12 '17 19:03 andreineculau

It is very similar but this one is more generic because it is not tied to a request. Code executed outside the context of a request makes it much cleaner IMHO.

danron avatar Mar 14 '17 06:03 danron