O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Verifying server-side routing and template rendering

We created a test to verify all the server-side routes of the IGWEB application. Each route that we test will be associated with an expected string token, which is rendered in the page response, particularly in the primary content div container. So, not only will we be able to verify if the server-side route is functioning properly or not, but we will also know if the server-side template rendering is functioning normally.

Here are the contents of the routes_test.go source file, found in the tests folder:

package testsimport (  "io/ioutil"  "net/http"  "strings"  "testing")func checkRoute(t *testing.T, route string, expectedToken string) {  testURL := testHost + route response, err := http.Get(testURL) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required