Skip to content

nanozuki/enpal-home-challege

Repository files navigation

enpal coding challenge

Build

  1. build the postgres image. I created some indexes to the postgres.
    docker build -t enpal-coding-challenge-db -f build/Dockerfile-db .
  2. build the app image
    docker build -t enpal-coding-challenge -f build/Dockerfile .

Run

Use docker-compose to run the app:

docker-compose up

Testing

When the docker compose is running, the port of postgres is listening on :5432. Use go test to run tests of mine:

POSTGRES_URL=postgres://postgres:mypassword123!@localhost:5432/coding-challenge?sslmode=disable \
LISTEN_ADDR=:3000 \
go run test ./tests

The first test suit is equal to the test-app in the challenge description.

WARNING: the testing will change the data in the database.

Benchmark

When the docker compose is running, the port of postgres is listening on :5432. Use go test to run benchmarks of mine:

POSTGRES_URL=postgres://postgres:mypassword123!@localhost:5432/coding-challenge?sslmode=disable \
LISTEN_ADDR=:3000 \
go test -bench=. ./tests/

WARNING: this command will change the data in the database.

I get a result in my machine:

goos: darwin
goarch: arm64
pkg: github.com/nanozuki/enpal-home-challege/tests
cpu: Apple M1 Max
BenchmarkCalendarQuery-10            643           1950088 ns/op

It says that the CalendarQuery function average time is 1.95 ms/op.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published