Skip to content

Commit

Permalink
Rename test channel to avoid conflict with other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Oct 24, 2024
1 parent 3752cbc commit 708e81e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/postgres/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,9 @@ async fn test_pg_listener_implements_acquire() -> anyhow::Result<()> {
let pool = pool::<Postgres>().await?;

let mut listener = PgListener::connect_with(&pool).await?;
listener.listen("test_channel").await?;
listener
.listen("test_pg_listener_implements_acquire")
.await?;

// Start a transaction on the underlying connection
let mut txn = listener.begin().await?;
Expand All @@ -1091,18 +1093,21 @@ async fn test_pg_listener_implements_acquire() -> anyhow::Result<()> {
.fetch_all(&mut *txn)
.await?;

assert_eq!(channels, vec!["test_channel"]);
assert_eq!(channels, vec!["test_pg_listener_implements_acquire"]);

// Send a notification
sqlx::query("NOTIFY test_channel, 'hello'")
sqlx::query("NOTIFY test_pg_listener_implements_acquire, 'hello'")
.execute(&mut *txn)
.await?;

txn.commit().await?;

// And now we can receive the notification we sent in the transaction
let notification = listener.recv().await?;
assert_eq!(notification.channel(), "test_channel");
assert_eq!(
notification.channel(),
"test_pg_listener_implements_acquire"
);
assert_eq!(notification.payload(), "hello");

Ok(())
Expand Down

0 comments on commit 708e81e

Please sign in to comment.