Skip to content

Commit

Permalink
build: update deps (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
hseeberger authored May 28, 2024
1 parent 0dfea1b commit 023bb60
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
25 changes: 8 additions & 17 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait-variant = { version = "0.1" }

[dev-dependencies]
sqlx = { version = "0.7", features = [ "uuid" ] }
testcontainers = { version = "0.16" }
testcontainers-modules = { version = "0.4", features = [ "postgres" ] }
testcontainers = { version = "0.17" }
testcontainers-modules = { version = "0.5", features = [ "postgres" ] }
tokio = { version = "1", features = [ "macros" ] }
uuid = { version = "1.8", features = [ "serde", "v7" ] }
27 changes: 18 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,13 @@ mod tests {
use error_ext::BoxError;
use serde::{Deserialize, Serialize};
use sqlx::{postgres::PgSslMode, Executor, Row, Transaction};
use std::error::Error as StdError;
use testcontainers::{runners::AsyncRunner, RunnableImage};
use testcontainers_modules::postgres::Postgres;
use uuid::Uuid;

type TestResult = Result<(), Box<dyn StdError>>;

#[derive(Debug, Default, PartialEq, Eq)]
pub struct Counter(u64);

Expand Down Expand Up @@ -426,12 +429,12 @@ mod tests {
}

#[tokio::test]
async fn test_load() {
async fn test_load() -> TestResult {
let container = RunnableImage::from(Postgres::default())
.with_tag("16-alpine")
.start()
.await;
let pg_port = container.get_host_port_ipv4(5432).await;
.await?;
let pg_port = container.get_host_port_ipv4(5432).await?;

let config = Config {
host: "localhost".to_string(),
Expand Down Expand Up @@ -474,15 +477,17 @@ mod tests {

let counter = Counter::default().entity().build(id, pool).await.unwrap();
assert_eq!(counter.entity.0, 42);

Ok(())
}

#[tokio::test]
async fn test_handle_command() {
async fn test_handle_command() -> TestResult {
let container = RunnableImage::from(Postgres::default())
.with_tag("16-alpine")
.start()
.await;
let pg_port = container.get_host_port_ipv4(5432).await;
.await?;
let pg_port = container.get_host_port_ipv4(5432).await?;

let config = Config {
host: "localhost".to_string(),
Expand Down Expand Up @@ -511,15 +516,17 @@ mod tests {
assert_eq!(result, Ok(&Counter(20)));
let result = counter.handle_command(Increase(22)).await.unwrap();
assert_eq!(result, Ok(&Counter(42)));

Ok(())
}

#[tokio::test]
async fn test_event_listener() {
async fn test_event_listener() -> TestResult {
let container = RunnableImage::from(Postgres::default())
.with_tag("16-alpine")
.start()
.await;
let pg_port = container.get_host_port_ipv4(5432).await;
.await?;
let pg_port = container.get_host_port_ipv4(5432).await?;

let config = Config {
host: "localhost".to_string(),
Expand Down Expand Up @@ -587,5 +594,7 @@ mod tests {
.unwrap()
.map(|row| row.get::<i64, _>(0));
assert_eq!(value, Some(2));

Ok(())
}
}
8 changes: 5 additions & 3 deletions src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ mod tests {
use testcontainers::{runners::AsyncRunner, RunnableImage};
use testcontainers_modules::postgres::Postgres;

type TestResult = Result<(), Box<dyn StdError>>;

#[tokio::test]
async fn test_pool() -> Result<(), Box<dyn StdError>> {
async fn test_pool() -> TestResult {
let container = RunnableImage::from(Postgres::default())
.with_tag("16-alpine")
.start()
.await;
let pg_port = container.get_host_port_ipv4(5432).await;
.await?;
let pg_port = container.get_host_port_ipv4(5432).await?;

let config = Config {
host: "localhost".to_string(),
Expand Down

0 comments on commit 023bb60

Please sign in to comment.