Redirecting from Filters in Revel

I was working on Login functionality for web app, and wanted to redirect user from Filter using Redirect, but rather then being redirected, I was seeing a blank page. The code looked something like this The idea being if there is userEmail set in session, proceed forward, otherwise redirect to homepage. It was not working. […]

Continue reading →

Validating Domain Objects in Revel

Moving further from showing a login/signup page, Now we need get user to fill up the sign up details, and validate them before saving in database. Consider User struct, as defined Further, consider that none of the above fields can be null or empty and FirstName and LastName are not more then 30 characters each. […]

Continue reading →

Integrating Gorp with Revel

Being a web developer, I have been itching to start developing web application with Go. I explored around the laziest way to build one, and shortlisted Revel to build my first web application with Go. The quick start guide for Revel is more then helpful in getting up and running. Like in most web apps, […]

Continue reading →

Checking for panic condition in test cases

Often when we write functions, we encounter panic situations, where a program must throw a panic which will be (Hopefully) handled by some other part of the system. More on panic and recover here. Consider a function which triggers a panic situation Now, while testing we want to ensure that this panic is indeed triggered. […]

Continue reading →

Mocking Functions while Unit Testing

Continuing from the last blog on testing, Here we will see how we can mock call to a function to ensure we test only one function at a time. Consider the following function, (taken from Post a tweet) When writing test case for serveHomePage(), we need to ensure that we do not invoke respond function. […]

Continue reading →

Unit Testing in Golang

Testing your code is as important as writing it in the first place. So, how do you write unit tests in go? Go provides a testing package, for writing automated test cases. In the example here, I have also used testify as an assertion library. Not spending more time let’s get to code. To begin […]

Continue reading →