service

package
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2022 License: AGPL-3.0 Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCommandStr

func GenerateCommandStr(t *testing.T, request *http.Request, flags test.Flags, body []byte) string

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 TestGetBookingsHelper(
	t *testing.T,
	mockDB *db.Mock,
	bookingID api.BookingId,
	flags test.Flags,
)

func TestGetDriverJourneysHelper

func TestGetDriverJourneysHelper(
	t *testing.T,
	mockDB *db.Mock,
	params *api.GetDriverJourneysParams,
	flags test.Flags,
)

func TestGetDriverRegularTripsHelper

func TestGetDriverRegularTripsHelper(
	t *testing.T,
	mockDB *db.Mock,
	params *api.GetDriverRegularTripsParams,
	flags test.Flags,
)

func TestGetPassengerJourneysHelper

func TestGetPassengerJourneysHelper(
	t *testing.T,
	mockDB *db.Mock,
	params *api.GetPassengerJourneysParams,
	flags test.Flags,
)

func TestGetPassengerRegularTripsHelper

func TestGetPassengerRegularTripsHelper(
	t *testing.T,
	mockDB *db.Mock,
	params *api.GetPassengerRegularTripsParams,
	flags test.Flags,
)

func TestPatchBookingsHelper

func TestPatchBookingsHelper(
	t *testing.T,
	mockDB *db.Mock,
	bookingID api.BookingId,
	status api.BookingStatus,
	flags test.Flags,
)

func TestPostBookingEventsHelper

func TestPostBookingEventsHelper(
	t *testing.T,
	mockDB *db.Mock,
	bookingEvent api.CarpoolBookingEvent,
	flags test.Flags,
)

func TestPostBookingsHelper

func TestPostBookingsHelper(
	t *testing.T,
	mockDB *db.Mock,
	booking api.Booking,
	flags test.Flags,
)

func TestPostMessagesHelper

func TestPostMessagesHelper(
	t *testing.T,
	mockDB *db.Mock,
	message api.PostMessagesJSONBody,
	flags test.Flags,
)

func UpdateBookingStatus

func UpdateBookingStatus(m db.DB, bookingID uuid.UUID, newStatus api.BookingStatus) error

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 Error

type Error struct {
	Error string `json:"error"`
}

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)

Directories

Path Synopsis
Package db handles data storage and manipulation for the API server.
Package db handles data storage and manipulation for the API server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL