aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2022-03-13 01:58:19 +0100
committerTeddy Wing2022-03-13 01:58:19 +0100
commitd2b6b8e5f3e54483f269e501816b9e275d59223f (patch)
treea4055171c8b6e3115594e4c3c72d695c77cfbd77 /src
parentde7c2af3414cf686165efd933b61da4e4527cf77 (diff)
downloadyaqlite-d2b6b8e5f3e54483f269e501816b9e275d59223f.tar.bz2
insert(): Test that an array of YAML records get inserted
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f8d0032..9ee48d4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -54,8 +54,7 @@ mod tests {
let mut stmt = conn.prepare(r#"
SELECT
id, count, weight, description
- FROM "test"
- LIMIT 1;
+ FROM "test";
"#).unwrap();
let rows = stmt.query_map(
@@ -135,6 +134,38 @@ r#"- description: >-
#[test]
fn inserts_multiple_records() {
+ let expected = vec![
+ TestRecord {
+ id: 1,
+ count: 10,
+ weight: 33.2,
+ description: "First".to_owned(),
+ },
+ TestRecord {
+ id: 2,
+ count: 12,
+ weight: 180.5,
+ description: "Second".to_owned(),
+ },
+ ];
+
+ let yaml_str = format!(
+r#"- description: {}
+ count: {}
+ weight: {}
+- description: {}
+ count: {}
+ weight: {}
+"#,
+ expected[0].description,
+ expected[0].count,
+ expected[0].weight,
+ expected[1].description,
+ expected[1].count,
+ expected[1].weight,
+ );
+
+ test_yaml_insert(&yaml_str, &expected);
}
#[test]