Skip to content

Commit f99264f

Browse files
committed
fix test
fix test fix test
1 parent ce88ca3 commit f99264f

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

tests/postgres/derives.rs

+11-16
Original file line numberDiff line numberDiff line change
@@ -378,21 +378,21 @@ SELECT $1 = ROW('fuzzy dice', 42, 199)::inventory_item, $1
378378
#[sqlx_macros::test]
379379
async fn test_new_type() {
380380
struct NewType(i32);
381-
let conn = new::<Postgres>().await.unwrap();
382-
conn.execute("CREATE TABLE new_type (id INTEGER)")
383-
.await
384-
.unwrap();
385381

386-
conn.execute("INSERT INTO new_type (id) VALUES (1)")
387-
.await
388-
.unwrap();
382+
impl From<i32> for NewType {
383+
fn from(value: i32) -> Self {
384+
NewType(value)
385+
}
386+
}
387+
388+
let mut conn = new::<Postgres>().await.unwrap();
389389

390390
struct NewTypeRow {
391391
id: NewType,
392392
}
393393

394-
let res = sqlx::query_as!(NewTypeRow, "SELECT id FROM new_type")
395-
.fetch_one(&conn)
394+
let res = sqlx::query_as!(NewTypeRow, "SELECT 1 as id")
395+
.fetch_one(&mut conn)
396396
.await
397397
.unwrap();
398398
assert_eq!(res.id.0, 1);
@@ -401,17 +401,12 @@ async fn test_new_type() {
401401
id: i32,
402402
}
403403

404-
let res = sqlx::query_as!(NormalRow, "SELECT id FROM new_type")
405-
.fetch_one(&conn)
404+
let res = sqlx::query_as!(NormalRow, "SELECT 1 as id")
405+
.fetch_one(&mut conn)
406406
.await
407407
.unwrap();
408408

409409
assert_eq!(res.id, 1);
410-
411-
sqlx::query!("DROP TABLE new_type")
412-
.execute(&conn)
413-
.await
414-
.unwrap();
415410
}
416411

417412
#[cfg(feature = "macros")]

0 commit comments

Comments
 (0)