draft tests
This commit is contained in:
@@ -11,13 +11,13 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
type bookingMongoAccessor struct {
|
||||
type BookingMongoAccessor struct {
|
||||
utils.AbstractAccessor // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
||||
}
|
||||
|
||||
// New creates a new instance of the bookingMongoAccessor
|
||||
func NewAccessor(request *tools.APIRequest) *bookingMongoAccessor {
|
||||
return &bookingMongoAccessor{
|
||||
// New creates a new instance of the BookingMongoAccessor
|
||||
func NewAccessor(request *tools.APIRequest) *BookingMongoAccessor {
|
||||
return &BookingMongoAccessor{
|
||||
AbstractAccessor: utils.AbstractAccessor{
|
||||
Logger: logs.CreateLogger(tools.BOOKING.String()), // Create a logger with the data type
|
||||
Request: request,
|
||||
@@ -29,11 +29,11 @@ func NewAccessor(request *tools.APIRequest) *bookingMongoAccessor {
|
||||
/*
|
||||
* Nothing special here, just the basic CRUD operations
|
||||
*/
|
||||
func (a *bookingMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return utils.GenericDeleteOne(id, a)
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||
if set.(*Booking).State == 0 {
|
||||
return nil, 400, errors.New("state is required")
|
||||
}
|
||||
@@ -41,15 +41,15 @@ func (a *bookingMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.D
|
||||
return utils.GenericUpdateOne(realSet, id, a, &Booking{})
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return utils.GenericStoreOne(data, a)
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return utils.GenericStoreOne(data, a)
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
return utils.GenericLoadOne[*Booking](id, func(d utils.DBObject) (utils.DBObject, int, error) {
|
||||
now := time.Now()
|
||||
now = now.Add(time.Second * -60)
|
||||
@@ -67,15 +67,15 @@ func (a *bookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
}, a)
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) LoadAll(isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) LoadAll(isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
return utils.GenericLoadAll[*Booking](a.getExec(), isDraft, a)
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
func (a *BookingMongoAccessor) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
return utils.GenericSearch[*Booking](filters, search, (&Booking{}).GetObjectFilters(search), a.getExec(), isDraft, a)
|
||||
}
|
||||
|
||||
func (a *bookingMongoAccessor) getExec() func(utils.DBObject) utils.ShallowDBObject {
|
||||
func (a *BookingMongoAccessor) getExec() func(utils.DBObject) utils.ShallowDBObject {
|
||||
return func(d utils.DBObject) utils.ShallowDBObject {
|
||||
now := time.Now()
|
||||
now = now.Add(time.Second * -60)
|
||||
|
||||
Reference in New Issue
Block a user