Skip to content

Commit 49c9132

Browse files
committed
test: add pgAdmin startup queries test for issue #178
Adds a test file to verify pgAdmin startup queries work correctly. The test covers: - SELECT version() query - The CASE expression checking pg_extension for 'bdr' extension and pg_replication_slots for replication slot count Both pg_extension and pg_replication_slots tables are already implemented in pg_catalog, so these queries now pass.
1 parent 37b2f72 commit 49c9132

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use pgwire::api::query::SimpleQueryHandler;
2+
3+
use datafusion_postgres::testing::*;
4+
5+
// pgAdmin startup queries from issue #178
6+
// https://github.com/datafusion-contrib/datafusion-postgres/issues/178
7+
const PGADMIN_QUERIES: &[&str] = &[
8+
// Basic version query (fixed by #179)
9+
"SELECT version()",
10+
// Query to check for BDR extension and replication slots
11+
r#"SELECT CASE
12+
WHEN (SELECT count(extname) FROM pg_catalog.pg_extension WHERE extname='bdr') > 0
13+
THEN 'pgd'
14+
WHEN (SELECT COUNT(*) FROM pg_replication_slots) > 0
15+
THEN 'log'
16+
ELSE NULL
17+
END as type"#,
18+
];
19+
20+
#[tokio::test]
21+
pub async fn test_pgadmin_startup_sql() {
22+
let service = setup_handlers();
23+
let mut client = MockClient::new();
24+
25+
for query in PGADMIN_QUERIES {
26+
SimpleQueryHandler::do_query(&service, &mut client, query)
27+
.await
28+
.unwrap_or_else(|e| {
29+
panic!("failed to run sql:\n--------------\n{query}\n--------------\n{e}")
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)