Skip to content

Commit 51dd40b

Browse files
committed
Add Readme
1 parent 2161139 commit 51dd40b

File tree

3 files changed

+74
-11
lines changed

3 files changed

+74
-11
lines changed

DEVELOPMENT.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Use a local SeaORM version
2+
3+
Add this to your `Cargo.toml` for you local project to test out your changes:
4+
5+
```toml
6+
[patch.crates-io]
7+
sea-orm = { path = "../sea-orm" }
8+
```
9+
10+
## Before submitting PR
11+
12+
### Run `clippy` and `fmt`
13+
14+
We need nightly to do the formatting,
15+
16+
```sh
17+
cargo +nightly fmt
18+
```
19+
20+
If you don't have nightly then at least run:
21+
22+
```sh
23+
cargo fmt && git checkout -- ./sea-orm-codegen/src/tests_cfg/
24+
```
25+
26+
We use latest stable clippy:
27+
28+
```sh
29+
cargo clippy --all
30+
```
31+
32+
### Running unit tests
33+
34+
Just do:
35+
36+
```sh
37+
cargo test --lib
38+
cargo test --doc
39+
```
40+
41+
### Launch some databases
42+
43+
There is a docker compose under `build-tools`, but usually I just pick the ones I need from `build-tools/docker-crete.sh`:
44+
45+
```sh
46+
docker run \
47+
--name "postgres-14" \
48+
--env POSTGRES_USER="sea" \
49+
--env POSTGRES_PASSWORD="sea" \
50+
-d -p 5432:5432 postgres:14
51+
```
52+
53+
### Running integration tests
54+
55+
You need to supply the right feature flags to run integration tests:
56+
57+
```sh
58+
DATABASE_URL="sqlite::memory:" cargo test --features sqlx-sqlite,runtime-tokio --test crud_tests
59+
DATABASE_URL="mysql://sea:sea@localhost" cargo test --features sqlx-mysql,runtime-tokio-native-tls --test crud_tests
60+
DATABASE_URL="postgres://sea:sea@localhost" cargo test --features sqlx-postgres,runtime-tokio-native-tls --test crud_tests
61+
```
62+
63+
Or use `--tests` to run all tests, which can take a while.

build-tools/docker-create.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,35 @@ docker stop "mysql-5.7"
6767

6868
docker run \
6969
--name "postgres-vector-14" \
70-
--env POSTGRES_USER="root" \
71-
--env POSTGRES_PASSWORD="root" \
70+
--env POSTGRES_USER="sea" \
71+
--env POSTGRES_PASSWORD="sea" \
7272
-d -p 5432:5432 pgvector/pgvector:pg14
7373
docker stop "postgres-vector-14"
7474

7575
docker run \
7676
--name "postgres-14" \
77-
--env POSTGRES_USER="root" \
78-
--env POSTGRES_PASSWORD="root" \
77+
--env POSTGRES_USER="sea" \
78+
--env POSTGRES_PASSWORD="sea" \
7979
-d -p 5432:5432 postgres:14
8080
docker stop "postgres-14"
8181

8282
docker run \
8383
--name "postgres-13" \
84-
--env POSTGRES_USER="root" \
85-
--env POSTGRES_PASSWORD="root" \
84+
--env POSTGRES_USER="sea" \
85+
--env POSTGRES_PASSWORD="sea" \
8686
-d -p 5432:5432 postgres:13
8787
docker stop "postgres-13"
8888

8989
docker run \
9090
--name "postgres-12" \
91-
--env POSTGRES_USER="root" \
92-
--env POSTGRES_PASSWORD="root" \
91+
--env POSTGRES_USER="sea" \
92+
--env POSTGRES_PASSWORD="sea" \
9393
-d -p 5432:5432 postgres:12
9494
docker stop "postgres-12"
9595

9696
docker run \
9797
--name "postgres-11" \
98-
--env POSTGRES_USER="root" \
99-
--env POSTGRES_PASSWORD="root" \
98+
--env POSTGRES_USER="sea" \
99+
--env POSTGRES_PASSWORD="sea" \
100100
-d -p 5432:5432 postgres:11
101101
docker stop "postgres-11"

tests/crud_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use sea_orm::DatabaseConnection;
1010
// Run the test locally:
1111
// DATABASE_URL="sqlite::memory:" cargo test --features rusqlite --test crud_tests
1212
// DATABASE_URL="sqlite::memory:" cargo test --features sqlx-sqlite,runtime-tokio --test crud_tests
13-
// DATABASE_URL="mysql://root:root@localhost" cargo test --features sqlx-mysql,runtime-tokio-native-tls --test crud_tests
13+
// DATABASE_URL="mysql://sea:sea@localhost" cargo test --features sqlx-mysql,runtime-tokio-native-tls --test crud_tests
1414
// DATABASE_URL="postgres://sea:sea@localhost" cargo test --features sqlx-postgres,runtime-tokio-native-tls --test crud_tests
1515
#[sea_orm_macros::test]
1616
async fn main() {

0 commit comments

Comments
 (0)