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
Diesel cli with postgres cargo install diesel_cli --no-default-features --features "postgres"
PostgreSQL database server or use our docker-compose.yml (require docker)
Getting Started
git clone https://github.com/clifinger/canduma.git
cd canduma
docker-compose up
cp .env.example .env
diesel setup --database-url='postgres://postgres:canduma@localhost/canduma'
diesel migration run
cargo run
Test the GraphQL API with Insomnia
Register
Login
Get my account
Get JWT Token
Set Bearer JWT Token
Get decoded JWT by the server (for tests purpose)
Test authentication with session in GraphQL by getting all users (for tests purpose)
To enable debug logging set RUST_LOG=debug in .env
Testing
Initialization
First run yarn or npm install to get all required packages
npm run test
To run you can use npm run test or yarn test.
The testing system designed to automatically build canduma offline and start in tests/jest.beforeall.js
We starting canduma in order to capture output from both rust and js code using testci target
npm run testci
$ npm run testci
> canduma@ testci /home/olexiyb/b100pro/canduma
> cross-env RUST_LOG=debug DEBUG=canduma:* NODE_ENV=test jest
Determining test suites to run...
$ killall canduma
canduma: no process found
$ cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
canduma:jest.beforeall.js build = { status: 0, signal: null, output: [ null, null, null ], pid: 2447, stdout: null, stderr: null } +0ms
$ target/debug/canduma
[2020-04-02T18:17:19Z INFO actix_server::builder] Starting 24 workers
[2020-04-02T18:17:19Z INFO actix_server::builder] Starting server on 0.0.0.0:4000
Listening on 0.0.0.0:4000
started API
canduma:user.test.js /user/me body='Unauthorized' text="Unauthorized" +0ms
...
[2020-04-02T18:17:22Z DEBUG canduma::user::handler] user_string={"user_uuid":"f7cfa71e-096e-44d0-ae4f-7d16dd9e4baf","email":"email1@nowhere.com","role":"bad_role"}
canduma:user.test.js /graphql body={ data: null, errors: [ { message: 'Unauthorized', locations: [Array], path: [Array], extensions: [Object] } ] } +292ms
PASS tests/user.test.js
...
In example above you see output from jest tests as well as from rust code debug!("user_string={}", user_string);
CLion
I also highly recommend to use CLion as a dev tool.
I allows to run all tests or individual with single click and analyze logs
About
A Rust server with GraphQL API, Diesel, PostgreSQL, session authentication and JWT