Documentation ¶
Overview ¶
Package service serves a fake API complying with standard covoiturage specification.
The server is launched wih the `Run` function, which optionally accepts the path to a data file (json format). See Package db documentation for more information about the data format. If an empty path is provided, then default data is loaded.
Index ¶
- func GenerateCommandStr(t *testing.T, request *http.Request, flags test.Flags, body []byte) string
- func NewBookingsByID(bookings ...*api.Booking) db.BookingsByID
- func Run(dataFile string)
- func TestGetBookingsHelper(t *testing.T, mockDB *db.Mock, bookingID api.BookingId, flags test.Flags)
- func TestGetDriverJourneysHelper(t *testing.T, mockDB *db.Mock, params *api.GetDriverJourneysParams, ...)
- func TestGetDriverRegularTripsHelper(t *testing.T, mockDB *db.Mock, params *api.GetDriverRegularTripsParams, ...)
- func TestGetPassengerJourneysHelper(t *testing.T, mockDB *db.Mock, params *api.GetPassengerJourneysParams, ...)
- func TestGetPassengerRegularTripsHelper(t *testing.T, mockDB *db.Mock, params *api.GetPassengerRegularTripsParams, ...)
- func TestPatchBookingsHelper(t *testing.T, mockDB *db.Mock, bookingID api.BookingId, ...)
- func TestPostBookingEventsHelper(t *testing.T, mockDB *db.Mock, bookingEvent api.CarpoolBookingEvent, ...)
- func TestPostBookingsHelper(t *testing.T, mockDB *db.Mock, booking api.Booking, flags test.Flags)
- func TestPostMessagesHelper(t *testing.T, mockDB *db.Mock, message api.PostMessagesJSONBody, ...)
- func UpdateBookingStatus(m db.DB, bookingID uuid.UUID, newStatus api.BookingStatus) error
- type Error
- type StatusAlreadySetErr
- type StdCovServerImpl
- func (s *StdCovServerImpl) GetBookings(ctx echo.Context, bookingID api.BookingId) error
- func (s *StdCovServerImpl) GetDriverJourneys(ctx echo.Context, params api.GetDriverJourneysParams) error
- func (s *StdCovServerImpl) GetDriverRegularTrips(ctx echo.Context, params api.GetDriverRegularTripsParams) error
- func (s *StdCovServerImpl) GetPassengerJourneys(ctx echo.Context, params api.GetPassengerJourneysParams) error
- func (s *StdCovServerImpl) GetPassengerRegularTrips(ctx echo.Context, params api.GetPassengerRegularTripsParams) error
- func (*StdCovServerImpl) GetStatus(ctx echo.Context) error
- func (s *StdCovServerImpl) PatchBookings(ctx echo.Context, bookingID api.BookingId, params api.PatchBookingsParams) error
- func (s *StdCovServerImpl) PostBookingEvents(ctx echo.Context) error
- func (s *StdCovServerImpl) PostBookings(ctx echo.Context) error
- func (s *StdCovServerImpl) PostMessages(ctx echo.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCommandStr ¶
GenerateCommandStr generates a string with the command that should be run to test the request with given flags and body.
Used to transform golang tests into command line tests.
func NewBookingsByID ¶
func NewBookingsByID(bookings ...*api.Booking) db.BookingsByID
NewBookingsByID populates a BookingsByID with given bookings. It does not test if booking is already set.
func Run ¶
func Run(dataFile string)
Run serves a server with an implementation of the API enforcing the "standard-covoiturage" specification
func TestGetBookingsHelper ¶
func TestPatchBookingsHelper ¶
func TestPostBookingsHelper ¶
func TestPostMessagesHelper ¶
func UpdateBookingStatus ¶
UpdateBookingStatus updates the status of a booking. Status can only be updated for a higher ranked status. If this is not the case, or if the booking is not found, returns an error
Types ¶
type StatusAlreadySetErr ¶
type StatusAlreadySetErr struct{}
func (StatusAlreadySetErr) Error ¶
func (err StatusAlreadySetErr) Error() string
type StdCovServerImpl ¶
type StdCovServerImpl struct {
// contains filtered or unexported fields
}
StdCovServerImpl implements server.ServerInterface
func NewDefaultServer ¶
func NewDefaultServer() *StdCovServerImpl
NewDefaultServer returns a server, and populates the associated DB with default data
func NewServer ¶
func NewServer() *StdCovServerImpl
func NewServerWithDB ¶
func NewServerWithDB(mockDB db.DB) *StdCovServerImpl
func (*StdCovServerImpl) GetBookings ¶
func (s *StdCovServerImpl) GetBookings(ctx echo.Context, bookingID api.BookingId) error
GetBookings retrieves an existing Booking request. (GET /bookings/{bookingId})
func (*StdCovServerImpl) GetDriverJourneys ¶
func (s *StdCovServerImpl) GetDriverJourneys( ctx echo.Context, params api.GetDriverJourneysParams, ) error
GetDriverJourneys searches for matching punctual planned outward driver journeys. (GET /driver_journeys)
func (*StdCovServerImpl) GetDriverRegularTrips ¶
func (s *StdCovServerImpl) GetDriverRegularTrips( ctx echo.Context, params api.GetDriverRegularTripsParams, ) error
GetDriverRegularTrips searches for matching regular driver trip. (GET /driver_regular_trips)
func (*StdCovServerImpl) GetPassengerJourneys ¶
func (s *StdCovServerImpl) GetPassengerJourneys( ctx echo.Context, params api.GetPassengerJourneysParams, ) error
GetPassengerJourneys searches for matching punctual planned outward pasenger journeys. (GET /passenger_journeys)
func (*StdCovServerImpl) GetPassengerRegularTrips ¶
func (s *StdCovServerImpl) GetPassengerRegularTrips( ctx echo.Context, params api.GetPassengerRegularTripsParams, ) error
GetPassengerRegularTrips searches for matching pasenger regular trips. (GET /passenger_regular_trips)
func (*StdCovServerImpl) GetStatus ¶
func (*StdCovServerImpl) GetStatus(ctx echo.Context) error
GetStatus gives health status of the webservice. (GET /status)
func (*StdCovServerImpl) PatchBookings ¶
func (s *StdCovServerImpl) PatchBookings(ctx echo.Context, bookingID api.BookingId, params api.PatchBookingsParams) error
PatchBookings updates status of an existing Booking request. (PATCH /bookings/{bookingId})
func (*StdCovServerImpl) PostBookingEvents ¶
func (s *StdCovServerImpl) PostBookingEvents(ctx echo.Context) error
PostBookingEvents sends booking information of a user connected with a third-party provider back to the provider. (POST /booking_events)
func (*StdCovServerImpl) PostBookings ¶
func (s *StdCovServerImpl) PostBookings(ctx echo.Context) error
PostBookings creates a punctual outward Booking request. (POST /bookings)
func (*StdCovServerImpl) PostMessages ¶
func (s *StdCovServerImpl) PostMessages(ctx echo.Context) error
PostMessages sends a mesage to the owner of a retrieved journey. (POST /messages)