feat: tipos TestServer y TestDB para utilidades de testing en Go core
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestDB encapsula una base de datos SQLite de test con su path y cleanup.
|
||||||
|
type TestDB struct {
|
||||||
|
DB *sql.DB
|
||||||
|
Path string
|
||||||
|
Cleanup func()
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestServer encapsula un servidor HTTP de test con su cliente y cleanup.
|
||||||
|
type TestServer struct {
|
||||||
|
URL string
|
||||||
|
Client *http.Client
|
||||||
|
Cleanup func()
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: test_db
|
||||||
|
lang: go
|
||||||
|
domain: core
|
||||||
|
version: "1.0.0"
|
||||||
|
algebraic: product
|
||||||
|
definition: |
|
||||||
|
type TestDB struct {
|
||||||
|
DB *sql.DB
|
||||||
|
Path string
|
||||||
|
Cleanup func()
|
||||||
|
}
|
||||||
|
description: "Base de datos SQLite de test con puntero al DB abierto, path (vacio para :memory:) y funcion de cleanup para cerrar conexiones al finalizar el test."
|
||||||
|
tags: [testing, database, sqlite, test_helper]
|
||||||
|
uses_types: []
|
||||||
|
file_path: "functions/core/test_db.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Tipo producto — todos los campos siempre presentes. Retornado por `test_db_setup_go_core`.
|
||||||
|
Path es `:memory:` para bases de datos en memoria.
|
||||||
|
Cleanup se registra automaticamente en t.Cleanup() al crear el DB.
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
name: test_server
|
||||||
|
lang: go
|
||||||
|
domain: core
|
||||||
|
version: "1.0.0"
|
||||||
|
algebraic: product
|
||||||
|
definition: |
|
||||||
|
type TestServer struct {
|
||||||
|
URL string
|
||||||
|
Client *http.Client
|
||||||
|
Cleanup func()
|
||||||
|
}
|
||||||
|
description: "Servidor HTTP de test con URL base, cliente preconfigurado y funcion de cleanup para liberar recursos al finalizar el test."
|
||||||
|
tags: [testing, http, server, test_helper]
|
||||||
|
uses_types: []
|
||||||
|
file_path: "functions/core/test_server.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Tipo producto — todos los campos siempre presentes. Retornado por `test_http_server_go_core`.
|
||||||
|
Cleanup se registra automaticamente en t.Cleanup() al crear el servidor.
|
||||||
Reference in New Issue
Block a user