Fix tests for improved logging of field and index errors
This commit is contained in:
parent
f9645e3d55
commit
a8497ff6b3
3 changed files with 12 additions and 12 deletions
|
@ -217,7 +217,7 @@ pub enum Error {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// A database index entry for the specified record already exists
|
/// 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 {
|
IndexExists {
|
||||||
thing: String,
|
thing: String,
|
||||||
index: String,
|
index: String,
|
||||||
|
@ -225,7 +225,7 @@ pub enum Error {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// The specified field did not conform to the field ASSERT clause
|
/// 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 {
|
FieldValue {
|
||||||
thing: String,
|
thing: String,
|
||||||
value: String,
|
value: String,
|
||||||
|
|
|
@ -654,7 +654,7 @@ async fn define_statement_index_single_unique() -> Result<(), Error> {
|
||||||
let tmp = res.remove(0).result;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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(())
|
Ok(())
|
||||||
|
@ -704,13 +704,13 @@ async fn define_statement_index_multiple_unique() -> Result<(), Error> {
|
||||||
let tmp = res.remove(0).result;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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(())
|
Ok(())
|
||||||
|
@ -743,13 +743,13 @@ async fn define_statement_index_single_unique_existing() -> Result<(), Error> {
|
||||||
let tmp = res.remove(0).result;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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?;
|
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;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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?;
|
let tmp = res.remove(0).result?;
|
||||||
|
|
|
@ -36,19 +36,19 @@ async fn field_definition_value_assert_failure() -> Result<(), Error> {
|
||||||
let tmp = res.remove(0).result;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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;
|
let tmp = res.remove(0).result;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
tmp.err(),
|
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(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue