genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[BUGFIX] test 100% again :D

This commit is contained in:
Martin Geno 2017-05-19 12:41:07 +02:00
parent 7fbc6c23f2
commit a3942f79b8
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
3 changed files with 11 additions and 7 deletions

View File

@ -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")
}

View File

@ -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)

View File

@ -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+'.'};
});
};
}]);