You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d808fd4
Browse filesBrowse the repository at this point in the historyBrowse files
SQLx uses docker to run many compatible database systems for integration testing. You'll need to [install docker](https://docs.docker.com/engine/) to run the full suite. You can validate your docker installation with:
5
-
6
-
$ docker run hello-world
7
-
8
-
Start the databases with `docker-compose` before running tests:
9
-
10
-
$ docker-compose up
11
-
12
-
Run all tests against all supported databases using:
13
-
14
-
$ ./x.py
15
-
16
-
If you see test failures, or want to run a more specific set of tests against a specific database, you can specify both the features to be tests and the DATABASE_URL. e.g.
17
-
18
-
$ DATABASE_URL=mysql://root:password@127.0.0.1:49183/sqlx cargo test --no-default-features --features macros,offline,any,all-types,mysql,native-tls
1
+
# Running tests
2
+
3
+
Install Rust through rustup and [Docker Compose](https://docs.docker.com/compose/install/).
4
+
Run the local test script from any directory:
5
+
6
+
```sh
7
+
./test.sh # all backends, stopping at the first failure
8
+
./test.sh sqlite # SQLite only; no Docker needed
9
+
./test.sh postgres # PostgreSQL 14
10
+
./test.sh mysql # MySQL 8
11
+
./test.sh mssql # SQL Server 2022
12
+
./test.sh odbc # ODBC against local PostgreSQL 16
13
+
```
14
+
15
+
Each database run starts a disposable container, waits for its test schema, and
16
+
publishes a randomly assigned port on loopback. The script uses that container's
17
+
connection string and removes it when the test command exits, including failures.
18
+
SQLite runs against a temporary copy of its fixture database.
19
+
The script does not use an existing `DATABASE_URL`, a saved ODBC DSN, or modify `~/.odbc.ini`.
20
+
The ODBC run requires unixODBC and the **PostgreSQL Unicode** driver on the host.
21
+
22
+
The PostgreSQL client-certificate authentication configuration is tested separately
23
+
by the **Postgres with SSL client cert** CI job.
24
+
25
+
For custom databases, set `DATABASE_URL` explicitly when invoking Cargo. These tests
26
+
create and modify database objects: use a disposable test database.
0 commit comments