[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()
|
||||
var good models.Good
|
||||
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.DeletedAt = &now
|
||||
db := database.Write.Save(&good)
|
||||
|
||||
db = database.Write.Save(&good)
|
||||
if db.Error != nil {
|
||||
log.Warnf("good could not delete: %s", db.Error)
|
||||
http.Error(w, "the good could not delete", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if db.RowsAffected != 1 {
|
||||
log.Warnf("good could not found: %s", db.Error)
|
||||
http.Error(w, "the good could not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
log.Info("done")
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ func TestDelGood(t *testing.T) {
|
|||
_, w = session.JSONRequest("DELETE", fmt.Sprintf("/api/good/%d", good.ID), nil)
|
||||
assertion.Equal(http.StatusNotFound, w.StatusCode)
|
||||
|
||||
time.Sleep(time.Millisecond)
|
||||
database.Close()
|
||||
|
||||
_, w = session.JSONRequest("DELETE", "/api/good/1", nil)
|
||||
|
|
|
@ -16,7 +16,7 @@ angular.module('microStock')
|
|||
$scope.obj = {};
|
||||
$scope.msg = {type:'success',text:'Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
|
||||
}, 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