From a8497ff6b3da519b2f49008b7d844038f85785be Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 10 Sep 2022 06:17:03 +0100 Subject: [PATCH] Fix tests for improved logging of field and index errors --- lib/src/err/mod.rs | 4 ++-- lib/tests/define.rs | 14 +++++++------- lib/tests/field.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/src/err/mod.rs b/lib/src/err/mod.rs index 16c43d90..dbd880ce 100644 --- a/lib/src/err/mod.rs +++ b/lib/src/err/mod.rs @@ -217,7 +217,7 @@ pub enum Error { }, /// A database index entry for the specified record already exists - #[error("Database index `{index}` already contains {value}, on record `{thing}`")] + #[error("Database index `{index}` already contains {value}, with record `{thing}`")] IndexExists { thing: String, index: String, @@ -225,7 +225,7 @@ pub enum Error { }, /// The specified field did not conform to the field ASSERT clause - #[error("Found {value} for field `{field}`, on record `{thing}`, but field must conform to: {check}")] + #[error("Found {value} for field `{field}`, with record `{thing}`, but field must conform to: {check}")] FieldValue { thing: String, value: String, diff --git a/lib/tests/define.rs b/lib/tests/define.rs index b0ee2ea3..42d75fde 100644 --- a/lib/tests/define.rs +++ b/lib/tests/define.rs @@ -654,7 +654,7 @@ async fn define_statement_index_single_unique() -> Result<(), Error> { let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains "test@surrealdb.com""# + Some(e) if e.to_string() == r#"Database index `test` already contains "test@surrealdb.com", with record `user:2`"# )); // Ok(()) @@ -704,13 +704,13 @@ async fn define_statement_index_multiple_unique() -> Result<(), Error> { let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains ["apple", "test@surrealdb.com"]"# + Some(e) if e.to_string() == r#"Database index `test` already contains ["apple", "test@surrealdb.com"], with record `user:3`"# )); // let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains ["tesla", "test@surrealdb.com"]"# + Some(e) if e.to_string() == r#"Database index `test` already contains ["tesla", "test@surrealdb.com"], with record `user:4`"# )); // Ok(()) @@ -743,13 +743,13 @@ async fn define_statement_index_single_unique_existing() -> Result<(), Error> { let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains "test@surrealdb.com""# + Some(e) if e.to_string() == r#"Database index `test` already contains "test@surrealdb.com", with record `user:3`"# )); // let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains "test@surrealdb.com""# + Some(e) if e.to_string() == r#"Database index `test` already contains "test@surrealdb.com", with record `user:3`"# )); // let tmp = res.remove(0).result?; @@ -797,13 +797,13 @@ async fn define_statement_index_multiple_unique_existing() -> Result<(), Error> let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains ["apple", "test@surrealdb.com"]"# + Some(e) if e.to_string() == r#"Database index `test` already contains ["apple", "test@surrealdb.com"], with record `user:3`"# )); // let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == r#"Database index `test` already contains ["apple", "test@surrealdb.com"]"# + Some(e) if e.to_string() == r#"Database index `test` already contains ["apple", "test@surrealdb.com"], with record `user:3`"# )); // let tmp = res.remove(0).result?; diff --git a/lib/tests/field.rs b/lib/tests/field.rs index 297b1b3b..ddc1440f 100644 --- a/lib/tests/field.rs +++ b/lib/tests/field.rs @@ -36,19 +36,19 @@ async fn field_definition_value_assert_failure() -> Result<(), Error> { let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == "Found NONE for field `age` but field must conform to: $value > 0" + Some(e) if e.to_string() == "Found NONE for field `age`, with record `person:test`, but field must conform to: $value > 0" )); // let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == "Found NONE for field `age` but field must conform to: $value > 0" + Some(e) if e.to_string() == "Found NONE for field `age`, with record `person:test`, but field must conform to: $value > 0" )); // let tmp = res.remove(0).result; assert!(matches!( tmp.err(), - Some(e) if e.to_string() == "Found NULL for field `age` but field must conform to: $value > 0" + Some(e) if e.to_string() == "Found NULL for field `age`, with record `person:test`, but field must conform to: $value > 0" )); // Ok(())