Fix tests

This commit is contained in:
eraden 2022-11-14 20:32:28 +01:00
parent e038eec40e
commit c74e61f1f6
4 changed files with 83 additions and 8 deletions

View File

@ -679,8 +679,8 @@ pub fn load(config_path: &str, opts: &impl UpdateConfig) -> SharedAppConfig {
match std::fs::read_to_string(config_path) { match std::fs::read_to_string(config_path) {
Ok(c) => { Ok(c) => {
let mut c = toml::from_str(&c).unwrap_or_else(|e| { let mut c = toml::from_str(&c).unwrap_or_else(|e| {
eprintln!("{}", e); eprintln!("{}. {}", e, config_path);
panic!("{}", e); panic!("{}. {}", e, config_path);
}); });
opts.update_config(&mut c); opts.update_config(&mut c);
SharedAppConfig::new(c) SharedAppConfig::new(c)

View File

@ -1,7 +1,7 @@
#[macro_export] #[macro_export]
macro_rules! db_t_ref { macro_rules! db_t_ref {
($t: ident) => { ($t: ident) => {
let config = config::default_load(&mut NoOpts); let config = config::load("../../tests/bazzar.toml", &mut NoOpts);
config config
.lock() .lock()
.database_mut() .database_mut()
@ -16,7 +16,7 @@ macro_rules! db_t_ref {
#[macro_export] #[macro_export]
macro_rules! db { macro_rules! db {
($config: ident, $db: ident) => { ($config: ident, $db: ident) => {
let $config = config::default_load(&mut NoOpts); let $config = config::load("../../tests/bazzar.toml", &mut NoOpts);
$config $config
.lock() .lock()
.database_mut() .database_mut()

View File

@ -1,6 +1,17 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
psql postgres postgres -c "DROP DATABASE bazzar_test" ./scripts/migrate.sh purge
psql postgres postgres -c "CREATE DATABASE bazzar_test"
sqlx migrate run --database-url='postgres://postgres@localhost/bazzar_test' rm ./crates/**/bazzar.toml
cargo test --all
cargo test --workspace --exclude database_manager
#cargo test --bin account-manager
#cargo test --bin email-sender
#cargo test --bin cart-manager
##cargo test --bin order_manager
##cargo test --bin payment-manager
#cargo test --bin search-manager
#cargo test --bin stock-manager
##cargo test --bin token_manager
#cargo test --bin bazzar

64
tests/bazzar.toml Normal file
View File

@ -0,0 +1,64 @@
[payment]
payu_client_id = 'Create payu account and copy here client_id'
payu_client_secret = 'Create payu account and copy here client_secret'
payu_client_merchant_id = 0
optional_payment = true
[web]
host = 'https://your.comain.com'
pass_salt = 'Generate it with bazzar generate-hash'
session_secret = '100 characters long random string'
jwt_secret = '100 characters long random string'
bind = '0.0.0.0'
port = 8080
signature = 'John Doe'
service_name = 'bazzar'
[mail]
sendgrid_secret = 'Create sendgrid account and copy credentials here'
sendgrid_api_key = 'Create sendgrid account and copy credentials here'
smtp_from = 'Valid sendgrid authorized email address. Example: contact@example.com'
[database]
url = 'postgres://postgres@localhost/bazzar'
[search]
sonic_search_addr = '[::1]:1491'
sonic_search_pass = 'SecretPassword'
sonic_ingest_addr = '[::1]:1491'
sonic_ingest_pass = 'SecretPassword'
rpc_port = 19332
rpc_bind = '0.0.0.0'
search_active = true
[files]
public_path = '/uploads'
local_path = '/var/local/bazzar'
[account_manager]
rpc_port = 19329
rpc_bind = '0.0.0.0'
mqtt_port = 1883
mqtt_bind = '0.0.0.0'
database_url = 'postgres://postgres@localhost/bazzar_accounts'
[cart_manager]
rpc_port = 19330
rpc_bind = '0.0.0.0'
mqtt_port = 1884
mqtt_bind = '0.0.0.0'
database_url = 'postgres://postgres@localhost/bazzar_carts'
[email_sender]
rpc_port = 19331
rpc_bind = '0.0.0.0'
mqtt_port = 1885
mqtt_bind = '0.0.0.0'
database_url = 'postgres://postgres@localhost/bazzar_emails'
[stocks]
rpc_port = 19333
rpc_bind = '0.0.0.0'
mqtt_port = 1886
mqtt_bind = '0.0.0.0'
database_url = 'postgres://postgres@localhost/bazzar_stocks'