From 5f8b19f73b1a506cdcc4a33113a10c470927d09d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 5 Apr 2022 19:53:20 +0200 Subject: insert(): Add a test with YAML keys referring to nonexistent columns --- src/insert.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/insert.rs b/src/insert.rs index 59c8850..0c9f45e 100644 --- a/src/insert.rs +++ b/src/insert.rs @@ -205,4 +205,28 @@ weight: {} test_yaml_insert(&yaml_str, &vec![expected]); } + + #[test] + fn insert_ignores_non_column_yaml_fields() { + let expected = TestRecord { + id: 1, + count: 102, + weight: 79.4, + description: "Some text content.".to_owned(), + }; + + let yaml_str = format!( +r#"description: {} +count: {} +weight: {} +key_is_not_a_column: 44 +not-a-column: Text that shouldn't be inserted. +"#, + expected.description, + expected.count, + expected.weight, + ); + + test_yaml_insert(&yaml_str, &vec![expected]); + } } -- cgit v1.2.3