diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d75b7a..2976a6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,9 @@ jobs: with: command: test args: --all-features + env: + REDIS_HOST: 0.0.0.0 + REDIS_PORT: 6379 fmt: name: Rustfmt diff --git a/tests/async_command_tests/mod.rs b/tests/async_command_tests/mod.rs index 1f22891..24bea80 100644 --- a/tests/async_command_tests/mod.rs +++ b/tests/async_command_tests/mod.rs @@ -9,11 +9,12 @@ use redis_ts::{ TsAggregationType, TsDuplicatePolicy, TsFilterOptions, TsInfo, TsMget, TsMrange, TsOptions, TsRange, }; +use std::env; use std::thread; use std::time::{Duration, SystemTime, UNIX_EPOCH}; async fn get_con() -> Connection { - let client = redis::Client::open("redis://localhost/").unwrap(); + let client = redis::Client::open(get_redis_url()).unwrap(); client.get_async_connection().await.unwrap() } @@ -426,3 +427,20 @@ pub async fn ts_queryindex(name: &str) { .unwrap(); assert!(index.contains(&name.to_string())); } + +fn get_redis_url() -> String { + let redis_host_key = "REDIS_HOST"; + let redis_host_port = "REDIS_PORT"; + + let redis_host = match env::var(redis_host_key) { + Ok(host) => host, + _ => "localhost".to_string(), + }; + + let redis_port = match env::var(redis_host_port) { + Ok(port) => port, + _ => "6379".to_string(), + }; + + format!("redis://{}:{}/", redis_host, redis_port) +} diff --git a/tests/test_async_commands.rs b/tests/test_async_commands.rs deleted file mode 100644 index 8b13789..0000000 --- a/tests/test_async_commands.rs +++ /dev/null @@ -1 +0,0 @@ -