Improving tests by handling multiple test cases
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user