{{Project-name}} service for Glugate as part of microservice architecture.
- Diesel cli
cargo install diesel_cli
(Needed initializing database and for running tests)
rocket
Web frameworkdiesel
ORM and Query Builderserde
Serialization frameworkvalidator
Validation librarylog
andstderrlog
Logging facadeclap
Library for parsing command line arguments and subcommandsslug
Generating slugs from unicode stringsrust-crypto
Cryptographic algorithms used for auth password managementrand
Random number generationchrono
Date and time librarydotenv
Loading from local .env filejsonwebtoken
Authenticationassert_cli
Integration testingrun_script
Used only in tests for generating test database to distinguish the main database when running tests
Install nightly
# install rustup
curl https://sh.rustup.rs -sSf | sh
rustup install nightly
# start postgresql and seed the database
cargo install diesel_cli --no-default-features --features "postgres"
diesel setup
cargo run
Simply run:
cargo test -- --test-threads 1
This will try to create *_test database and run all migrations, so make sure you have correct postgress access in ./env.test
file.
For development, you probably want to set the username to postgres
and password to corresponding (main) postgres password.
You can also check Postman testing. See /tests/Glugate.postman_collection.json
flie which can be imported into Postman.
Note that Postman test are running against the main database ( not the *_test one as integrations test do ),
but on successful tests, all the test data should be cleaned up as we call DELETE method at the end.
TODO: Looks like the main database must be clear from test {{database-name}}. So currently , in order to pass all tests, it is best to run them against empty database.
To run restclient file tests you can run ad hoc testing. See /tests/dev.http
Note that in order to run the Postman and http tests, you need to run the application first.
diesel
cli uses .env
file.
Rocket sets database configuration from .env
file.
Checkout Rocket's amazing guide