(
in_channel: &Channel<ContainerCommands>,
host_channel: &Channel<String>,
port_channel: &Channel<u16>,
stopped_channel: &Channel<()>,
)
| 108 | } |
| 109 | |
| 110 | async fn start_postgres( |
| 111 | in_channel: &Channel<ContainerCommands>, |
| 112 | host_channel: &Channel<String>, |
| 113 | port_channel: &Channel<u16>, |
| 114 | stopped_channel: &Channel<()>, |
| 115 | ) { |
| 116 | info!("Starting postgres test container with user postgres/postgres and db test"); |
| 117 | |
| 118 | let container = postgres::Postgres::default() |
| 119 | .with_user("postgres") |
| 120 | .with_password("postgres") |
| 121 | .with_db_name("test") |
| 122 | .with_mapped_port(16432, 5432.tcp()) |
| 123 | .with_tag("17-alpine") |
| 124 | .start() |
| 125 | .await |
| 126 | .unwrap(); |
| 127 | // uncomment this if you are running docker in docker |
| 128 | // let host = "host.docker.internal".to_string(); |
| 129 | let host = container.get_host().await.unwrap().to_string(); |
| 130 | let port = container.get_host_port_ipv4(5432).await.unwrap(); |
| 131 | |
| 132 | let mut rx = in_channel.rx.lock().await; |
| 133 | while let Some(command) = rx.recv().await { |
| 134 | match command { |
| 135 | FetchHost => host_channel.tx.send(host.clone()).unwrap(), |
| 136 | FetchPort => port_channel.tx.send(port).unwrap(), |
| 137 | ContainerCommands::Stop => { |
| 138 | container.stop().await.unwrap(); |
| 139 | stopped_channel.tx.send(()).unwrap(); |
| 140 | rx.close(); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | fn is_pg_uri_set() -> bool { |
| 147 | env::var("PG_URI").is_ok() |
no test coverage detected
searching dependent graphs…