Improving tests by handling multiple test cases

This commit is contained in:
2024-07-13 16:47:23 +02:00
parent f67aed4942
commit 0f17b3405e
3 changed files with 49 additions and 33 deletions

View File

@ -1,6 +1,7 @@
package dbrepo
import (
"errors"
"go-udemy-web-1/internal/models"
"time"
)
@ -33,5 +34,9 @@ func (m *testDBRepo) SearchAvailabilityForAllRooms(start, end time.Time) ([]mode
// GetRoomById gets a room by id
func (m *testDBRepo) GetRoomById(id int) (models.Room, error) {
var room models.Room
if id > 2 {
return room, errors.New("Deliberate error")
}
return room, nil
}