Private
Public Access
añadidos tests y hecho workflow de testing
Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
1 parent
1e74e4363e
commit
37f1741a77
12 files changed
+391
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package stock
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
ctrl "repuestera_back/controllers/stock"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TestActualizarObservacion_Validacion(t *testing.T) {
|
||||
texto := ""
|
||||
for i := 0; i < 61; i++ {
|
||||
texto += "a"
|
||||
}
|
||||
context, recorder := newStockContext(t, "PATCH", "/stock/1/observacion", map[string]any{
|
||||
"observacion": texto,
|
||||
}, gin.Params{{Key: "id", Value: "1"}})
|
||||
ctrl.ActualizarObservacion(context)
|
||||
if recorder.Code != 400 {
|
||||
t.Fatalf("observación larga: esperado 400, obtenido %d", recorder.Code)
|
||||
}
|
||||
|
||||
context, recorder = newStockContext(t, "PATCH", "/stock/abc/observacion", map[string]any{
|
||||
"observacion": "ok",
|
||||
}, gin.Params{{Key: "id", Value: "abc"}})
|
||||
ctrl.ActualizarObservacion(context)
|
||||
if recorder.Code != 400 {
|
||||
t.Fatalf("id inválido: esperado 400, obtenido %d", recorder.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestActualizarObservacion_Integracion(t *testing.T) {
|
||||
context, recorder := newIntegrationContext(t, "PATCH", "/stock/1/observacion", map[string]any{
|
||||
"observacion": "test integracion",
|
||||
}, gin.Params{{Key: "id", Value: "1"}})
|
||||
ctrl.ActualizarObservacion(context)
|
||||
if recorder.Code != 200 {
|
||||
t.Fatalf("actualizar observación: esperado 200, obtenido %d: %s", recorder.Code, recorder.Body.String())
|
||||
}
|
||||
|
||||
context, recorder = newIntegrationContext(t, "PATCH", "/stock/1/observacion", map[string]any{
|
||||
"observacion": "",
|
||||
}, gin.Params{{Key: "id", Value: "1"}})
|
||||
ctrl.ActualizarObservacion(context)
|
||||
if recorder.Code != 200 {
|
||||
t.Fatalf("vaciar observación: esperado 200, obtenido %d: %s", recorder.Code, recorder.Body.String())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user