diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4cfe6e6..d9bc254 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -679,8 +679,8 @@ pub fn load(config_path: &str, opts: &impl UpdateConfig) -> SharedAppConfig { match std::fs::read_to_string(config_path) { Ok(c) => { let mut c = toml::from_str(&c).unwrap_or_else(|e| { - eprintln!("{}", e); - panic!("{}", e); + eprintln!("{}. {}", e, config_path); + panic!("{}. {}", e, config_path); }); opts.update_config(&mut c); SharedAppConfig::new(c) diff --git a/crates/testx/src/lib.rs b/crates/testx/src/lib.rs index e91896b..25c1f69 100644 --- a/crates/testx/src/lib.rs +++ b/crates/testx/src/lib.rs @@ -1,7 +1,7 @@ #[macro_export] macro_rules! db_t_ref { ($t: ident) => { - let config = config::default_load(&mut NoOpts); + let config = config::load("../../tests/bazzar.toml", &mut NoOpts); config .lock() .database_mut() @@ -16,7 +16,7 @@ macro_rules! db_t_ref { #[macro_export] macro_rules! db { ($config: ident, $db: ident) => { - let $config = config::default_load(&mut NoOpts); + let $config = config::load("../../tests/bazzar.toml", &mut NoOpts); $config .lock() .database_mut() diff --git a/scripts/test.sh b/scripts/test.sh index db67aba..a48d370 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,6 +1,17 @@ #!/usr/bin/env zsh -psql postgres postgres -c "DROP DATABASE bazzar_test" -psql postgres postgres -c "CREATE DATABASE bazzar_test" -sqlx migrate run --database-url='postgres://postgres@localhost/bazzar_test' -cargo test --all +./scripts/migrate.sh purge + +rm ./crates/**/bazzar.toml + +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 diff --git a/tests/bazzar.toml b/tests/bazzar.toml new file mode 100644 index 0000000..9af59ac --- /dev/null +++ b/tests/bazzar.toml @@ -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'