File tree Expand file tree Collapse file tree 4 files changed +51
-56
lines changed
Expand file tree Collapse file tree 4 files changed +51
-56
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -28,7 +28,30 @@ mod tests {
2828 use testcontainers:: runners:: AsyncRunner ;
2929 use testcontainers:: GenericImage ;
3030 use crate :: flow_queue:: connection:: build_connection;
31- use crate :: rabbitmq_container_test;
31+
32+ macro_rules! rabbitmq_container_test {
33+ ( $test_name: ident, $consumer: expr) => {
34+
35+ #[ tokio:: test]
36+ async fn $test_name( ) {
37+ let port: u16 = 5672 ;
38+ let image_name = "rabbitmq" ;
39+ let wait_message = "Server startup complete" ;
40+
41+ let container = GenericImage :: new( image_name, "latest" )
42+ . with_exposed_port( port. tcp( ) )
43+ . with_wait_for( WaitFor :: message_on_stdout( wait_message) )
44+ . start( )
45+ . await
46+ . unwrap( ) ;
47+
48+ let host_port = container. get_host_port_ipv4( port) . await . unwrap( ) ;
49+ let url = format!( "amqp://guest:guest@localhost:{}" , host_port) ;
50+
51+ $consumer( url) . await ;
52+ }
53+ } ;
54+ }
3255
3356 rabbitmq_container_test ! ( test_rabbitmq_startup, ( |url: String | async move {
3457 println!( "RabbitMQ started with the url: {}" , url) ;
Original file line number Diff line number Diff line change 11use std:: sync:: Arc ;
22use redis:: aio:: MultiplexedConnection ;
3- use redis:: { Client , RedisResult } ;
3+ use redis:: { Client } ;
44use tokio:: sync:: Mutex ;
55
66pub type FlowStore = Arc < Mutex < Box < MultiplexedConnection > > > ;
@@ -29,7 +29,31 @@ mod tests {
2929 use testcontainers:: GenericImage ;
3030 use testcontainers:: core:: WaitFor ;
3131 use crate :: flow_store:: connection:: build_connection;
32- use crate :: redis_container_test;
32+
33+ macro_rules! redis_container_test {
34+ ( $test_name: ident, $consumer: expr) => {
35+
36+ #[ tokio:: test]
37+ async fn $test_name( ) {
38+ let port: u16 = 6379 ;
39+ let image_name = "redis" ;
40+ let wait_message = "Ready to accept connections" ;
41+
42+ let container = GenericImage :: new( image_name, "latest" )
43+ . with_exposed_port( port. tcp( ) )
44+ . with_wait_for( WaitFor :: message_on_stdout( wait_message) )
45+ . start( )
46+ . await
47+ . unwrap( ) ;
48+
49+ let host = container. get_host( ) . await . unwrap( ) ;
50+ let host_port = container. get_host_port_ipv4( port) . await . unwrap( ) ;
51+ let url = format!( "redis://{host}:{host_port}" ) ;
52+
53+ $consumer( url) . await ;
54+ }
55+ } ;
56+ }
3357
3458 redis_container_test ! ( test_redis_startup, ( |url: String | async move {
3559 println!( "Redis server started correctly on: {}" , url) ;
Original file line number Diff line number Diff line change 22pub mod flow_store;
33
44#[ cfg( feature = "flow_queue" ) ]
5- pub mod flow_queue;
6-
7- pub mod container;
5+ pub mod flow_queue;
You can’t perform that action at this time.
0 commit comments