fix bugs and add tests for PostMakeReservation handler
This commit is contained in:
		@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user