From 92e71f4b78f8c6a998312b8410cd0ec76d209832 Mon Sep 17 00:00:00 2001 From: Duncan Fairbanks Date: Wed, 27 Nov 2024 18:37:25 -0800 Subject: [PATCH] chore: add tests of Error::InvalidSavePointStatement --- tests/mysql/error.rs | 14 ++++++++++++++ tests/postgres/error.rs | 14 ++++++++++++++ tests/sqlite/error.rs | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/tests/mysql/error.rs b/tests/mysql/error.rs index 090cbe1980..3ee1024fc8 100644 --- a/tests/mysql/error.rs +++ b/tests/mysql/error.rs @@ -86,3 +86,17 @@ async fn it_fails_with_begin_failed() -> anyhow::Result<()> { Ok(()) } + +#[sqlx_macros::test] +async fn it_fails_with_invalid_save_point_statement() -> anyhow::Result<()> { + let mut conn = new::().await?; + let mut txn = conn.begin().await?; + let txn_conn = sqlx::Acquire::acquire(&mut txn).await?; + let res = txn_conn.begin_with("BEGIN").await; + + let err = res.unwrap_err(); + + assert!(matches!(err, Error::InvalidSavePointStatement), "{err}"); + + Ok(()) +} diff --git a/tests/postgres/error.rs b/tests/postgres/error.rs index 5e52155f33..32bf814770 100644 --- a/tests/postgres/error.rs +++ b/tests/postgres/error.rs @@ -86,3 +86,17 @@ async fn it_fails_with_begin_failed() -> anyhow::Result<()> { Ok(()) } + +#[sqlx_macros::test] +async fn it_fails_with_invalid_save_point_statement() -> anyhow::Result<()> { + let mut conn = new::().await?; + let mut txn = conn.begin().await?; + let txn_conn = sqlx::Acquire::acquire(&mut txn).await?; + let res = txn_conn.begin_with("BEGIN").await; + + let err = res.unwrap_err(); + + assert!(matches!(err, Error::InvalidSavePointStatement), "{err}"); + + Ok(()) +} diff --git a/tests/sqlite/error.rs b/tests/sqlite/error.rs index 2227a14d3b..8729842b70 100644 --- a/tests/sqlite/error.rs +++ b/tests/sqlite/error.rs @@ -82,3 +82,17 @@ async fn it_fails_with_begin_failed() -> anyhow::Result<()> { Ok(()) } + +#[sqlx_macros::test] +async fn it_fails_with_invalid_save_point_statement() -> anyhow::Result<()> { + let mut conn = new::().await?; + let mut txn = conn.begin().await?; + let txn_conn = sqlx::Acquire::acquire(&mut txn).await?; + let res = txn_conn.begin_with("BEGIN").await; + + let err = res.unwrap_err(); + + assert!(matches!(err, Error::InvalidSavePointStatement), "{err}"); + + Ok(()) +}