fix bugs and add tests for PostMakeReservation handler

This commit is contained in:
2024-07-14 11:49:42 +02:00
parent 262b48161d
commit d76070c21d
4 changed files with 226 additions and 76 deletions

View File

@ -12,11 +12,18 @@ func (m *testDBRepo) AllUsers() bool {
// InsertReservation inserts a reservation into the database
func (m *testDBRepo) InsertReservation(res models.Reservation) (int, error) {
// if the room id is 2, then fail; otherwise, pass
if res.RoomID == 2 {
return 0, errors.New("deliberate error")
}
return 1, nil
}
// InsertRoomRestriction inserts a room restriction into the database
func (m *testDBRepo) InsertRoomRestriction(r models.RoomRestriction) error {
if r.RoomID == 100 {
return errors.New("deliberate error")
}
return nil
}
@ -36,7 +43,7 @@ func (m *testDBRepo) GetRoomById(id int) (models.Room, error) {
var room models.Room
if id > 2 {
return room, errors.New("Deliberate error")
return room, errors.New("deliberate error")
}
return room, nil
}