Installation

Docker + docker-compose must be installed to run the chat server + database. https://docs.docker.com/compose/install/

Gomock must be installed to run tests.

To install gomock (assuming go is installed)

GO111MODULE=on go get github.com/golang/mock/mockgen@latest

Build and Run chat server

Using Makefile:

make run

Usually the server restarts a few times before the db comes up. Once the logs stop writing the server should be ready to accept requests on localhost port 8080.

Run tests

Once gomock is installed, using Makefile:

make test

With race check:

make test-race

Chat cli / integration testing

Once server is up and running you can run some quick tests to check that everything is working using the chat cli.

To create cli binary (assuming go is installed)

go build -o chatCli cmd/cli/*

Create test users:

./chatCli -cmd=createUsers

Send messages:

./chatCli -user=yoda -rec=luke -cmd=sendMsg

Get messages:

./chatCli -user=yoda -rec=luke -cmd=getMsg -start=0 -limit=5 | jq '.'