Skip to content

Commit

Permalink
fix testcontainers dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
sphenlee committed Mar 4, 2024
1 parent df0ca5f commit e7c1574
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
16 changes: 13 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ uuid = { version = "1.1.2", features = [ "v4", "serde" ] }
xxhash-rust = { version = "0.8.6", features = ["xxh3"] }

[dev-dependencies]
testcontainers-modules = { version = "0.3.5", features = ["rabbitmq", "postgres", "redis"] }
pretty_assertions = "1.2.1"
testcontainers = { git = "http://github.com/sphenlee/testcontainers-rs", branch = "feature/slee/upgrade-bollard" }
18 changes: 15 additions & 3 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use highnoon::Result;
use std::{future::Future, sync::Once};
use waterwheel::config::{self, Config};
use testcontainers_modules::{
rabbitmq::RabbitMq,
postgres::Postgres,
redis::{Redis, REDIS_PORT},
testcontainers
};

const DEFAULT_LOG: &str = "warn,waterwheel=trace,highnoon=info,testcontainers=info,lapin=off";
static LOGGING_SETUP: Once = Once::new();
Expand All @@ -24,17 +30,23 @@ where
let client = testcontainers::clients::Cli::default();

// start database
let postgres = client.run(testcontainers::images::postgres::Postgres::default());
let postgres = client.run(Postgres::default()
.with_password("testpassword"));

let port = postgres.get_host_port_ipv4(5432);
config.db_url = format!("postgres://postgres@localhost:{}/", port);
config.db_url = format!("postgres://postgres:testpassword@localhost:{}/", port);

// start AMQP
let rabbit = client.run(testcontainers::images::rabbitmq::RabbitMq);
let rabbit = client.run(RabbitMq);

let port = rabbit.get_host_port_ipv4(5672);
config.amqp_addr = format!("amqp://localhost:{}//", port);

// start redis
let redis = client.run(Redis::default());
let port = redis.get_host_port_ipv4(REDIS_PORT);
config.redis_url = format!("redis://localhost:{}", port);

// other config setup
config.server_addr = "http://127.0.0.1:0/".to_owned();
config.no_authz = true;
Expand Down

0 comments on commit e7c1574

Please sign in to comment.