Assignement for Go.
Write a simple library application that will have two components API and database. Your application should be able to accept a book detail and store that in database and similarly it should be able to list all the books that are there in the database. API is going to accept HTTP GET and POST method to get and store data successfully. It will be nice to write unit test for above code.
https://github.com/infracloudio/citadel-internal/blob/master/modules/go/README.md#task
Setup installed packages.
go mod download
Run the server locally
go run cmd/web/!(*_test).go
Run test cases
go test -v ./cmd/web/
Build this project
go build ./cmd/web/
Test cases written for this project tests the handlers funactionality. Techniques used ot test the handlers is by creating a temporary DB instance.
- Write test cases using data mock pattern.
- Create API documentaion.
Articles in the below blog helped to create a this project.
-
Stackoverflow