Take Home Task for.... Took approx 5hr.
- Run docker-compose to access Postgres instance.
- Apply
up.sql
$ docker-compose up -d
$ go run cmd/api/main.go
I use Goland and run the tests from within handlers_test.go
. Alternatively:
$ go test ./...
$ curl -i http://localhost:8000/YH-nYjDnR
$ go run cmd/cli/main.go ge
5681
nerate http://www.bbc.co.uk
- Move tests to TDD. Create Interface for db abstraction.
- Isolate shorten fn so I can use !reflect.DeepEqual rather than asserting individual fields
- Postgres may not be the best choice of db vs e.g. redis.
- Wrapping the end json made it harder to test.
The file serve.go
file in addition to the ReadJSON helper function are inspired by 'Alex Edwards', granted they are edited/simplified. Otherwise, all work is my own.
William Noble 13th October 2021.