[BUGFIX] test 100% again :D
This commit is contained in:
parent
7fbc6c23f2
commit
a3942f79b8
15
http/good.go
15
http/good.go
|
@ -88,17 +88,20 @@ func delGood(w http.ResponseWriter, r *http.Request) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
var good models.Good
|
var good models.Good
|
||||||
good.ID = id
|
good.ID = id
|
||||||
|
db := good.FilterAvailable(database.Read).First(&good)
|
||||||
|
if db.RecordNotFound() {
|
||||||
|
log.Warnf("good could not found: %s", db.Error)
|
||||||
|
http.Error(w, "the good could not found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
good.ManuelleDelete = true
|
good.ManuelleDelete = true
|
||||||
good.DeletedAt = &now
|
good.DeletedAt = &now
|
||||||
db := database.Write.Save(&good)
|
|
||||||
|
db = database.Write.Save(&good)
|
||||||
if db.Error != nil {
|
if db.Error != nil {
|
||||||
log.Warnf("good could not delete: %s", db.Error)
|
log.Warnf("good could not delete: %s", db.Error)
|
||||||
http.Error(w, "the good could not delete", http.StatusInternalServerError)
|
http.Error(w, "the good could not delete", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if db.RowsAffected != 1 {
|
log.Info("done")
|
||||||
log.Warnf("good could not found: %s", db.Error)
|
|
||||||
http.Error(w, "the good could not found", http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,7 @@ func TestDelGood(t *testing.T) {
|
||||||
_, w = session.JSONRequest("DELETE", fmt.Sprintf("/api/good/%d", good.ID), nil)
|
_, w = session.JSONRequest("DELETE", fmt.Sprintf("/api/good/%d", good.ID), nil)
|
||||||
assertion.Equal(http.StatusNotFound, w.StatusCode)
|
assertion.Equal(http.StatusNotFound, w.StatusCode)
|
||||||
|
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
database.Close()
|
database.Close()
|
||||||
|
|
||||||
_, w = session.JSONRequest("DELETE", "/api/good/1", nil)
|
_, w = session.JSONRequest("DELETE", "/api/good/1", nil)
|
||||||
|
|
|
@ -16,7 +16,7 @@ angular.module('microStock')
|
||||||
$scope.obj = {};
|
$scope.obj = {};
|
||||||
$scope.msg = {type:'success',text:'Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
|
$scope.msg = {type:'success',text:'Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
|
||||||
}, function(){
|
}, function(){
|
||||||
$scope.msg = {type:'error',text:'Error: Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
|
$scope.msg = {type:'error',text:'Error: During saving of '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
Reference in New Issue