In my application, I need a functionality where one request fetches a token(random string) from the server which is stored in the session and the second request is made with this token.
When I make the requests in my tests using ring-mock, the second request says the token is not in session. I assume both requests are independent in test scenario.
How do I maintain a session when issuing multiple requests using ring-mock for writing tests? Or is there any other library that I can use for tests in such cases?
Introduction Ring is a library for writing web applications in Clojure. It supports everything needed to write fully-featured web apps and has a thriving ecosystem to make it even more powerful. In this tutorial, we'll give an introduction to Ring, and show some of the things that can we can achieve with it.
Clojure also offers a way to chain many together in a more natural way – by the use of Threading Macros. These are a way to provide a list of functions to call, each with the output of the previous one. In particular, we want the Thread First macro, ->.
By default, this stores session data in memory. We can change this if needed, and Ring comes with an alternative store that uses cookies to store all of the session data.
As per the suggestion by James Reeves through twitter, I was able to solve this problem by using peridot. It has session handling for writing tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With