add with http code
This commit is contained in:
@@ -9,29 +9,29 @@ type StorageMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) DeleteOne(id string) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return sma.GenericDeleteOne(id, sma)
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
return sma.GenericUpdateOne(set, id, sma)
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return sma.GenericStoreOne(data, sma)
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) LoadOne(id string) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
|
||||
var storage StorageResource
|
||||
|
||||
res_mongo, err := mongo.MONGOService.LoadOne(id, sma.GetType())
|
||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, sma.GetType())
|
||||
if err != nil {
|
||||
sma.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return nil, err
|
||||
return nil, code, err
|
||||
}
|
||||
|
||||
res_mongo.Decode(&storage)
|
||||
|
||||
return &storage, nil
|
||||
return &storage, 200, nil
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ func TestStoreOneStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
sma := StorageMongoAccessor{}
|
||||
id, _ := sma.StoreOne(&s)
|
||||
id, _, _ := sma.StoreOne(&s)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestLoadOneStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
sma := StorageMongoAccessor{}
|
||||
new_s, _ := sma.StoreOne(&s)
|
||||
new_s, _, _ := sma.StoreOne(&s)
|
||||
|
||||
assert.Equal(t, s, new_s)
|
||||
}
|
||||
|
Reference in New Issue
Block a user