This project simulates the behavior of a cleaning robot.
The project is divided into two packages: robot
and app
The robot
package contains the core logic of the robot, and it can be used as a standalone library.
The app
package is a http rest api that stores the robot's cleaning data into a Postgres database.
go get github.com/IuryAlves/cleaning-robot
package main
import "github.com/IuryAlves/cleaning-robot/robot"
// Initialise the robot into position (0, 0)
r := robot.New(0, 0)
// Move robot to position (1, 1)
r.Move(1, 1)
fmt.Println(r.Location()) // {1, 1}
For the full robot documentation see here.
Create a copy of .env.example
and replace the values with the configuration from your environment.
NOTE: The default configuration from
.env.example
is meant to work on a local environment.
cp .env.example .env
NOTE: The
.env
file is read automatically bydocker compose
.
docker compose up --build
curl \
-XPOST \
-H 'Content-Type: application/json' \
-d '{
"start": {
"x":10,
"y": 22
},
"commands": [
{"direction": "east", "steps": 2},
{"direction": "north", "steps": 1}
]
}' \
localhost:8080/tibber-developer-test/enter-path
output:
{"id":10,"timestamp":"2022-12-27T19:30:56.244522731Z","commands":2,"result":4,"duration":116578}
make test
NOTE: If running the integration tests against a new database, the migrations must be run first.
make integration-test