Skip to content

Commit

Permalink
Merge pull request #7 from tompro/develop
Browse files Browse the repository at this point in the history
Fixed integration tests missing redis connection by using IP 0.0.0.0 instead of localhost. Something changed with GH Actions docker networking?
  • Loading branch information
tompro authored Feb 14, 2021
2 parents ce0853c + da3da93 commit 5075417
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
with:
command: test
args: --all-features
env:
REDIS_HOST: 0.0.0.0
REDIS_PORT: 6379

fmt:
name: Rustfmt
Expand Down
20 changes: 19 additions & 1 deletion tests/async_command_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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)
}
1 change: 0 additions & 1 deletion tests/test_async_commands.rs

This file was deleted.

0 comments on commit 5075417

Please sign in to comment.