Private
Public Access
34 lines
1022 B
Go
34 lines
1022 B
Go
package stock
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ctrl "repuestera_back/controllers/stock"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestObtenerStock_Integracion(t *testing.T) {
|
|
context, recorder := newIntegrationContext(t, "GET", "/stock/", nil, nil)
|
|
ctrl.ObtenerStock(context)
|
|
if recorder.Code != 200 {
|
|
t.Fatalf("obtener stock: esperado 200, obtenido %d: %s", recorder.Code, recorder.Body.String())
|
|
}
|
|
}
|
|
|
|
func TestObtenerStockPorID_Validacion(t *testing.T) {
|
|
context, recorder := newStockContext(t, "GET", "/stock/abc", nil, gin.Params{{Key: "id", Value: "abc"}})
|
|
ctrl.ObtenerStockPorID(context)
|
|
if recorder.Code != 400 {
|
|
t.Fatalf("id inválido: esperado 400, obtenido %d", recorder.Code)
|
|
}
|
|
}
|
|
|
|
func TestObtenerStockPorID_Integracion(t *testing.T) {
|
|
context, recorder := newIntegrationContext(t, "GET", "/stock/1", nil, gin.Params{{Key: "id", Value: "1"}})
|
|
ctrl.ObtenerStockPorID(context)
|
|
if recorder.Code != 200 {
|
|
t.Fatalf("obtener stock por id: esperado 200, obtenido %d: %s", recorder.Code, recorder.Body.String())
|
|
}
|
|
}
|