In this section, you are going to see how to test a database server, which in this case is going to be a PostgreSQL server that works with an HTTP server written in Go. This is a special situation because you will have to get your database data in order to be able to test the correctness of the HTTP server.
For the purposes of this section, I am going to show two Go files named webServer.go and webServer_test.go. Before executing the code, you will need to download the Go package that will help you to work with PostgreSQL from Go, which requires the execution of the following command:
$ go get github.com/lib/pq
The Go code of webServer.go is as follows:
package main import ( "database/sql" "fmt" _ "github.com/lib/pq" "net/http" "os" "time...