Skip to content

Commit

Permalink
session_test: add checking getting specification by name
Browse files Browse the repository at this point in the history
One of the test cases is slightly amended to also check
the mechanism which retrieves column specification
from the query result.
  • Loading branch information
psarna committed Jul 23, 2021
1 parent 2f1332c commit 2dc1cc7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions scylla/src/transport/session_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,24 @@ async fn test_unprepared_statement() {
.await
.unwrap();

let rs = session
let query_result = session
.query("SELECT a, b, c FROM ks.t", &[])
.await
.unwrap()
.rows
.unwrap();

let (a_idx, _) = query_result.get_spec_by_name("a").unwrap();
let (b_idx, _) = query_result.get_spec_by_name("b").unwrap();
let (c_idx, _) = query_result.get_spec_by_name("c").unwrap();
assert!(query_result.get_spec_by_name("d").is_none());

let rs = query_result.rows.unwrap();

let mut results: Vec<(i32, i32, &String)> = rs
.iter()
.map(|r| {
let a = r.columns[0].as_ref().unwrap().as_int().unwrap();
let b = r.columns[1].as_ref().unwrap().as_int().unwrap();
let c = r.columns[2].as_ref().unwrap().as_text().unwrap();
let a = r.columns[a_idx].as_ref().unwrap().as_int().unwrap();
let b = r.columns[b_idx].as_ref().unwrap().as_int().unwrap();
let c = r.columns[c_idx].as_ref().unwrap().as_text().unwrap();
(a, b, c)
})
.collect();
Expand Down

0 comments on commit 2dc1cc7

Please sign in to comment.