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