Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSQLServerConfig ¶
GetSQLServerConfig builds a neat.DBConfig for SQL Server from environment variables. It reads the following variables with the shown defaults:
- SQLSERVER_HOST (default: 127.0.0.1)
- SQLSERVER_PORT (default: 1433)
- SQLSERVER_DATABASE (default: test)
- SQLSERVER_USER (default: sa)
- SQLSERVER_PASS (default: YourStrong@Passw0rd)
The returned config uses "sqlserver" as the default connection name and applies sensible connection-pool defaults (5 idle / 10 open connections, 1-hour lifetimes).
func SetupSQLServerConnection ¶
SetupSQLServerConnection returns a bare SQL Server connection without creating tables or seeding data. It is intended for connection-level tests (e.g. pool settings, connection switching) that need a live database but manage their own schema.
Like SetupSQLServerTest it uses a two-step connection strategy: it first connects to "master" to create the test database if absent, then returns a connection scoped to that test database. The connection is closed automatically via t.Cleanup.
func SetupSQLServerTest ¶
SetupSQLServerTest sets up a fully initialised SQL Server connection for integration tests.
SQL Server containers (e.g. via Docker Compose) start with only the system databases (master, model, msdb, tempdb) present. Unlike MySQL/Postgres, they do not automatically create user databases from environment variables. This function therefore uses a two-step connection strategy:
- Connect to the "master" system database (which always exists) and create the test database if it does not already exist using an idempotent IF NOT EXISTS guard.
- Connect directly to the test database, create the required test tables, and truncate any pre-existing data so each test begins with a clean slate.
The database connection is registered with t.Cleanup so it is closed automatically when the test (or sub-test) finishes.
Types ¶
This section is empty.