From a1d759a2f40a5f7b8f7ed276b8a8cda6ceb2496a Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Fri, 27 Apr 2018 17:34:13 -0700 Subject: [PATCH] Add test for simple query --- postgres/tests/test.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/postgres/tests/test.rs b/postgres/tests/test.rs index b8e3b354..971f7d62 100644 --- a/postgres/tests/test.rs +++ b/postgres/tests/test.rs @@ -1488,3 +1488,21 @@ fn explicit_types() { .unwrap(); assert_eq!(stmt.param_types()[0], Type::INT8); } + +#[test] +fn simple_query() { + let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap(); + conn.batch_execute( + " + CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY); + INSERT INTO foo (id) VALUES (1), (2), (3); + ", + ).unwrap(); + let queries = "SELECT id FROM foo WHERE id = 1 ORDER BY id; \ + SELECT id FROM foo WHERE id != 1 ORDER BY id"; + + let results = conn.simple_query(queries).unwrap(); + assert_eq!(results[0].get(0).get("id"), "1"); + assert_eq!(results[1].get(0).get("id"), "2"); + assert_eq!(results[1].get(1).get("id"), "3"); +}