Implement a guest list service for a company's end of the year party! The venue has not been chosen yet so the number of tables and the capacity are subject to change.
When the party begins, guests will arrive with an entourage. This party may not be the size indicated on the guest list. However, if it is expected that the guest's table can accommodate the extra people, then the whole party should be let in. Otherwise, they will be turned away. Guests will also leave throughout the course of the party. Note that when a guest leaves, their accompanying guests will leave with them.
At any point in the party, the following data should be known:
- Number of guests at the party
- How many empty seats there are
If there is insufficient space at the specified table, then an error should be thrown.
POST /guest_list/name
body:
{
"table": int,
"accompanying_guests": int
}
response:
{
"name": "string"
}
GET /guest_list
response:
{
"guests": [
{
"name": "string",
"table": int,
"accompanying_guests": int
}, ...
]
}
A guest may arrive with an entourage that is not the size indicated at the guest list. If the table is expected to have space for the extras, allow them to come. Otherwise, this method should throw an error.
PUT /guests/name
body:
{
"accompanying_guests": int
}
response:
{
"name": "string"
}
When a guest leaves, all their accompanying guests leave as well.
DELETE /guests/name
GET /guests
response:
{
"guests": [
{
"name": "string",
"accompanying_guests": int,
"time_arrived": "string"
}
]
}
GET /seats_empty
response:
{
"seats_empty": int
}
To run the application:
make docker-up
To run the tests
go test -v $(go list ./... | grep test)