añadidos tests y hecho workflow de testing

Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
fede committed 2026-11-19 08:55:08 -03:00
1 parent 1e74e4363e
commit 37f1741a77
12 files changed
+391

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
package stock
import (
"testing"
ctrl "repuestera_back/controllers/stock"
)
func TestAjustarStock_Validacion(t *testing.T) {
context, recorder := newStockContext(t, "POST", "/stock/ajustes", map[string]any{}, nil)
ctrl.AjustarStock(context)
if recorder.Code != 400 {
t.Fatalf("ajuste sin datos: esperado 400, obtenido %d", recorder.Code)
}
context, recorder = newStockContext(t, "POST", "/stock/ajustes", map[string]any{
"stockId": 1,
"cantidadReal": -1,
"motivo": "test",
}, nil)
ctrl.AjustarStock(context)
if recorder.Code != 400 {
t.Fatalf("ajuste negativo: esperado 400, obtenido %d", recorder.Code)
}
context, recorder = newStockContext(t, "POST", "/stock/ajustes", map[string]any{
"stockId": 1,
"cantidadReal": 10,
"motivo": "",
}, nil)
ctrl.AjustarStock(context)
if recorder.Code != 400 {
t.Fatalf("ajuste sin motivo: esperado 400, obtenido %d", recorder.Code)
}
}