Skip to content

Commit e66428e

Browse files
committed
update unit tests
1 parent 9778e2f commit e66428e

File tree

3 files changed

+13
-80
lines changed

3 files changed

+13
-80
lines changed

Diff for: tests/mysql/types.rs

+5-27
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::str::FromStr;
88
use std::sync::Arc;
99

1010
use sqlx::mysql::MySql;
11-
use sqlx::{Executor, FromRow, Row};
11+
use sqlx::{Executor, Row};
1212

1313
use sqlx::types::Text;
1414

@@ -310,9 +310,13 @@ test_type!(test_rc<Rc<i32>>(MySql, "1" == Rc::new(1i32)));
310310

311311
test_type!(test_box_str<Box<str>>(MySql, "'John'" == Box::<str>::from("John")));
312312
test_type!(test_cow_str<Cow<'_, str>>(MySql, "'Phil'" == Cow::<'static, str>::from("Phil")));
313+
test_type!(test_arc_str<Arc<str>>(MySql, "'John'" == Arc::<str>::from("John")));
314+
test_type!(test_rc_str<Rc<str>>(MySql, "'Phil'" == Rc::<str>::from("Phil")));
313315

314316
test_prepared_type!(test_box_slice<Box<[u8]>>(MySql, "X'01020304'" == Box::<[u8]>::from([1,2,3,4])));
315317
test_prepared_type!(test_cow_slice<Cow<'_, [u8]>>(MySql, "X'01020304'" == Cow::<'static, [u8]>::from(&[1,2,3,4])));
318+
test_prepared_type!(test_arc_slice<Arc<[u8]>>(MySql, "X'01020304'" == Arc::<[u8]>::from([1,2,3,4])));
319+
test_prepared_type!(test_rc_slice<Rc<[u8]>>(MySql, "X'01020304'" == Rc::<[u8]>::from([1,2,3,4])));
316320

317321
#[sqlx_macros::test]
318322
async fn test_bits() -> anyhow::Result<()> {
@@ -398,29 +402,3 @@ CREATE TEMPORARY TABLE user_login (
398402

399403
Ok(())
400404
}
401-
402-
#[sqlx_macros::test]
403-
async fn test_arc_str_slice() -> anyhow::Result<()> {
404-
let mut conn = new::<MySql>().await?;
405-
406-
let arc_str: Arc<str> = "Paul".into();
407-
let arc_slice: Arc<[u8]> = [5, 0].into();
408-
let rc_str: Rc<str> = "George".into();
409-
let rc_slice: Rc<[u8]> = [5, 0].into();
410-
411-
let row = sqlx::query("SELECT ?, ?, ?, ?")
412-
.bind(&arc_str)
413-
.bind(&arc_slice)
414-
.bind(&rc_str)
415-
.bind(&rc_slice)
416-
.fetch_one(&mut conn)
417-
.await?;
418-
419-
let data: (Arc<str>, Arc<[u8]>, Rc<str>, Rc<[u8]>) = FromRow::from_row(&row)?;
420-
421-
assert!(data.0 == arc_str);
422-
assert!(data.1 == arc_slice);
423-
assert!(data.2 == rc_str);
424-
assert!(data.3 == rc_slice);
425-
Ok(())
426-
}

Diff for: tests/postgres/types.rs

+4-26
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,13 @@ test_type!(test_rc<Rc<i32>>(Postgres, "1::INT4" == Rc::new(1i32)));
663663

664664
test_type!(test_box_str<Box<str>>(Postgres, "'John'::TEXT" == Box::<str>::from("John")));
665665
test_type!(test_cow_str<Cow<'_, str>>(Postgres, "'Phil'::TEXT" == Cow::<'static, str>::from("Phil")));
666+
test_type!(test_arc_str<Arc<str>>(Postgres, "'John'::TEXT" == Arc::<str>::from("John")));
667+
test_type!(test_rc_str<Rc<str>>(Postgres, "'John'::TEXT" == Rc::<str>::from("John")));
666668

667669
test_prepared_type!(test_box_slice<Box<[u8]>>(Postgres, "'\\x01020304'::BYTEA" == Box::<[u8]>::from([1,2,3,4])));
668670
test_prepared_type!(test_cow_slice<Cow<'_, [u8]>>(Postgres, "'\\x01020304'::BYTEA" == Cow::<'static, [u8]>::from(&[1,2,3,4])));
671+
test_prepared_type!(test_arc_slice<Arc<[u8]>>(Postgres, "'\\x01020304'::BYTEA" == Arc::<[u8]>::from([1,2,3,4])));
672+
test_prepared_type!(test_rc_slice<Rc<[u8]>>(Postgres, "'\\x01020304'::BYTEA" == Rc::<[u8]>::from([1,2,3,4])));
669673

670674
#[sqlx_macros::test]
671675
async fn test_text_adapter() -> anyhow::Result<()> {
@@ -709,29 +713,3 @@ CREATE TEMPORARY TABLE user_login (
709713

710714
Ok(())
711715
}
712-
713-
#[sqlx_macros::test]
714-
async fn test_arc_str_slice() -> anyhow::Result<()> {
715-
let mut conn = new::<Postgres>().await?;
716-
717-
let arc_str: Arc<str> = "Paul".into();
718-
let arc_slice: Arc<[u8]> = [5, 0].into();
719-
let rc_str: Rc<str> = "George".into();
720-
let rc_slice: Rc<[u8]> = [5, 0].into();
721-
722-
let row = sqlx::query("SELECT $1, $2, $3, $4")
723-
.bind(&arc_str)
724-
.bind(&arc_slice)
725-
.bind(&rc_str)
726-
.bind(&rc_slice)
727-
.fetch_one(&mut conn)
728-
.await?;
729-
730-
let data: (Arc<str>, Arc<[u8]>, Rc<str>, Rc<[u8]>) = FromRow::from_row(&row)?;
731-
732-
assert!(data.0 == arc_str);
733-
assert!(data.1 == arc_slice);
734-
assert!(data.2 == rc_str);
735-
assert!(data.3 == rc_slice);
736-
Ok(())
737-
}

Diff for: tests/sqlite/types.rs

+4-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate time_ as time;
22

33
use sqlx::sqlite::{Sqlite, SqliteRow};
4-
use sqlx::FromRow;
54
use sqlx_core::executor::Executor;
65
use sqlx_core::row::Row;
76
use sqlx_core::types::Text;
@@ -219,9 +218,13 @@ test_type!(test_rc<Rc<i32>>(Sqlite, "1" == Rc::new(1i32)));
219218

220219
test_type!(test_box_str<Box<str>>(Sqlite, "'John'" == Box::<str>::from("John")));
221220
test_type!(test_cow_str<Cow<'_, str>>(Sqlite, "'Phil'" == Cow::<'static, str>::from("Phil")));
221+
test_type!(test_arc_str<Arc<str>>(Sqlite, "'John'" == Arc::<str>::from("John")));
222+
test_type!(test_rc_str<Rc<str>>(Sqlite, "'John'" == Rc::<str>::from("John")));
222223

223224
test_type!(test_box_slice<Box<[u8]>>(Sqlite, "X'01020304'" == Box::<[u8]>::from([1,2,3,4])));
224225
test_type!(test_cow_slice<Cow<'_, [u8]>>(Sqlite, "X'01020304'" == Cow::<'static, [u8]>::from(&[1,2,3,4])));
226+
test_type!(test_arc_slice<Arc<[u8]>>(Sqlite, "X'01020304'" == Arc::<[u8]>::from([1,2,3,4])));
227+
test_type!(test_rc_slice<Rc<[u8]>>(Sqlite, "X'01020304'" == Rc::<[u8]>::from([1,2,3,4])));
225228

226229
#[sqlx_macros::test]
227230
async fn test_text_adapter() -> anyhow::Result<()> {
@@ -265,29 +268,3 @@ CREATE TEMPORARY TABLE user_login (
265268

266269
Ok(())
267270
}
268-
269-
#[sqlx_macros::test]
270-
async fn test_arc_str_slice() -> anyhow::Result<()> {
271-
let mut conn = new::<Sqlite>().await?;
272-
273-
let arc_str: Arc<str> = "Paul".into();
274-
let arc_slice: Arc<[u8]> = [5, 0].into();
275-
let rc_str: Rc<str> = "George".into();
276-
let rc_slice: Rc<[u8]> = [5, 0].into();
277-
278-
let row = sqlx::query("SELECT ?, ?, ?, ?")
279-
.bind(&arc_str)
280-
.bind(&arc_slice)
281-
.bind(&rc_str)
282-
.bind(&rc_slice)
283-
.fetch_one(&mut conn)
284-
.await?;
285-
286-
let data: (Arc<str>, Arc<[u8]>, Rc<str>, Rc<[u8]>) = FromRow::from_row(&row)?;
287-
288-
assert!(data.0 == arc_str);
289-
assert!(data.1 == arc_slice);
290-
assert!(data.2 == rc_str);
291-
assert!(data.3 == rc_slice);
292-
Ok(())
293-
}

0 commit comments

Comments
 (0)