* Move core implementations to a standalone crate * Set up integration test skeleton in `core` * Demonstrate mock testing with query * Move Rocket api code to a standalone crate * Add mock execution * Add MyDataMyConsent in COMMUNITY.md (#889) * Add MyDataMyConsent in COMMUNITY.md * Update MyDataMyConsent description in COMMUNITY.md * Update COMMUNITY.md Chronological order * [cli] bump sea-schema to 0.9.3 (SeaQL/sea-orm#876) * Update CHNAGELOG PR links * 0.9.1 CHANGELOG * Auto discover and run all issues & examples CI (#903) * Auto discover and run all [issues] CI * Auto discover and run all examples CI * Fixup * Testing * Test [issues] * Compile prepare_mock_db() conditionally based on "mock" feature * Update workflow job to run mock test if `core` folder exists * Update Actix3 example * Fix merge conflict human error * Update usize used in paginate to u64 (PR#789) * Update sea-orm version in the Rocket example to 0.10.0 * Fix GitHub workflow to run mock test for core crates * Increase the robustness of core crate check by verifying that the `core` folder is a crate * Update Actix(4) example * Update Axum example * Update GraphQL example * Update Jsonrpsee example * Update Poem example * Update Tonic example * Cargo fmt * Update Salvo example * Update path of core/Cargo.toml in README.md * Add mock test instruction in README.md * Refactoring * Fix Rocket examples Co-authored-by: Amit Goyani <63532626+itsAmitGoyani@users.noreply.github.com> Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
72 lines
1.4 KiB
Markdown
72 lines
1.4 KiB
Markdown
# jsonrpsee with SeaORM example app
|
|
|
|
1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database
|
|
|
|
1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-sqlite",` line)
|
|
|
|
1. Execute `cargo run` to start the server
|
|
|
|
1. Send jsonrpc request to server
|
|
|
|
```shell
|
|
#insert
|
|
curl --location --request POST 'http://127.0.0.1:8000' \
|
|
--header 'Content-Type: application/json' \
|
|
--data-raw '{"jsonrpc": "2.0", "method": "Post.Insert", "params": [
|
|
{
|
|
"id":0,
|
|
"title":"aaaaaaa",
|
|
"text":"aaaaaaa"
|
|
}
|
|
], "id": 2}'
|
|
|
|
#list
|
|
curl --location --request POST 'http://127.0.0.1:8000' \
|
|
--header 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"jsonrpc": "2.0",
|
|
"method": "Post.List",
|
|
"params": [
|
|
1,
|
|
100
|
|
],
|
|
"id": 2
|
|
}'
|
|
|
|
#delete
|
|
curl --location --request POST 'http://127.0.0.1:8000' \
|
|
--header 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"jsonrpc": "2.0",
|
|
"method": "Post.Delete",
|
|
"params": [
|
|
10
|
|
],
|
|
"id": 2
|
|
}'
|
|
|
|
#update
|
|
curl --location --request POST 'http://127.0.0.1:8000' \
|
|
--header 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"jsonrpc": "2.0",
|
|
"method": "Post.Update",
|
|
"params": [
|
|
{
|
|
"id": 1,
|
|
"title": "1111",
|
|
"text": "11111"
|
|
}
|
|
],
|
|
"id": 2
|
|
}'
|
|
|
|
```
|
|
|
|
Run mock test on the core logic crate:
|
|
|
|
```bash
|
|
cd core
|
|
cargo test --features mock
|
|
```
|