Fix tests for improved logging of field and index errors

This commit is contained in:
Tobie Morgan Hitchcock 2022-09-10 06:17:03 +01:00
parent f9645e3d55
commit a8497ff6b3
3 changed files with 12 additions and 12 deletions

View file

@ -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,

View file

@ -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?;

View file

@ -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(())