Skip to content

Commit 5075417

Browse files
authored
Merge pull request #7 from tompro/develop
Fixed integration tests missing redis connection by using IP 0.0.0.0 instead of localhost. Something changed with GH Actions docker networking?
2 parents ce0853c + da3da93 commit 5075417

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
with:
5050
command: test
5151
args: --all-features
52+
env:
53+
REDIS_HOST: 0.0.0.0
54+
REDIS_PORT: 6379
5255

5356
fmt:
5457
name: Rustfmt

tests/async_command_tests/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ use redis_ts::{
99
TsAggregationType, TsDuplicatePolicy, TsFilterOptions, TsInfo, TsMget, TsMrange, TsOptions,
1010
TsRange,
1111
};
12+
use std::env;
1213
use std::thread;
1314
use std::time::{Duration, SystemTime, UNIX_EPOCH};
1415

1516
async fn get_con() -> Connection {
16-
let client = redis::Client::open("redis://localhost/").unwrap();
17+
let client = redis::Client::open(get_redis_url()).unwrap();
1718
client.get_async_connection().await.unwrap()
1819
}
1920

@@ -426,3 +427,20 @@ pub async fn ts_queryindex(name: &str) {
426427
.unwrap();
427428
assert!(index.contains(&name.to_string()));
428429
}
430+
431+
fn get_redis_url() -> String {
432+
let redis_host_key = "REDIS_HOST";
433+
let redis_host_port = "REDIS_PORT";
434+
435+
let redis_host = match env::var(redis_host_key) {
436+
Ok(host) => host,
437+
_ => "localhost".to_string(),
438+
};
439+
440+
let redis_port = match env::var(redis_host_port) {
441+
Ok(port) => port,
442+
_ => "6379".to_string(),
443+
};
444+
445+
format!("redis://{}:{}/", redis_host, redis_port)
446+
}

tests/test_async_commands.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)