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 {
28
28
use testcontainers:: runners:: AsyncRunner ;
29
29
use testcontainers:: GenericImage ;
30
30
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
+ }
32
55
33
56
rabbitmq_container_test ! ( test_rabbitmq_startup, ( |url: String | async move {
34
57
println!( "RabbitMQ started with the url: {}" , url) ;
Original file line number Diff line number Diff line change 1
1
use std:: sync:: Arc ;
2
2
use redis:: aio:: MultiplexedConnection ;
3
- use redis:: { Client , RedisResult } ;
3
+ use redis:: { Client } ;
4
4
use tokio:: sync:: Mutex ;
5
5
6
6
pub type FlowStore = Arc < Mutex < Box < MultiplexedConnection > > > ;
@@ -29,7 +29,31 @@ mod tests {
29
29
use testcontainers:: GenericImage ;
30
30
use testcontainers:: core:: WaitFor ;
31
31
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
+ }
33
57
34
58
redis_container_test ! ( test_redis_startup, ( |url: String | async move {
35
59
println!( "Redis server started correctly on: {}" , url) ;
Original file line number Diff line number Diff line change 2
2
pub mod flow_store;
3
3
4
4
#[ 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