From 67eb4b97a10103ba889138ffb01280f49c59c593 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 19 Oct 2022 15:48:50 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20tests=20=F0=9F=98=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/sql/datetime.rs | 10 +++++----- lib/src/sql/range.rs | 4 ++-- lib/src/sql/strand.rs | 10 +++++----- lib/src/sql/thing.rs | 4 ++-- lib/src/sql/uuid.rs | 4 ++-- lib/src/sql/version.rs | 2 +- lib/tests/define.rs | 34 +++++++++++++++++----------------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/src/sql/datetime.rs b/lib/src/sql/datetime.rs index 3a07b83c..1d2c8773 100644 --- a/lib/src/sql/datetime.rs +++ b/lib/src/sql/datetime.rs @@ -263,7 +263,7 @@ mod tests { let res = datetime_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"2012-04-23T18:25:43Z\"", format!("{}", out)); + assert_eq!("'2012-04-23T18:25:43Z'", format!("{}", out)); } #[test] @@ -272,7 +272,7 @@ mod tests { let res = datetime_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"2012-04-23T18:25:43.563100Z\"", format!("{}", out)); + assert_eq!("'2012-04-23T18:25:43.563100Z'", format!("{}", out)); } #[test] @@ -281,7 +281,7 @@ mod tests { let res = datetime_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"2012-04-23T18:25:43.000051100Z\"", format!("{}", out)); + assert_eq!("'2012-04-23T18:25:43.000051100Z'", format!("{}", out)); } #[test] @@ -290,7 +290,7 @@ mod tests { let res = datetime_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"2012-04-24T02:25:43.511Z\"", format!("{}", out)); + assert_eq!("'2012-04-24T02:25:43.511Z'", format!("{}", out)); } #[test] @@ -299,6 +299,6 @@ mod tests { let res = datetime_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"2012-04-24T02:55:43.511Z\"", format!("{}", out)); + assert_eq!("'2012-04-24T02:55:43.511Z'", format!("{}", out)); } } diff --git a/lib/src/sql/range.rs b/lib/src/sql/range.rs index 32632d9a..13eec1fe 100644 --- a/lib/src/sql/range.rs +++ b/lib/src/sql/range.rs @@ -55,7 +55,7 @@ mod tests { let res = range(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#"person:["USA", 10]..["USA", 100]"#, format!("{}", out)); + assert_eq!("person:['USA', 10]..['USA', 100]", format!("{}", out)); } #[test] @@ -65,7 +65,7 @@ mod tests { assert!(res.is_ok()); let out = res.unwrap().1; assert_eq!( - r#"person:{ country: "USA", position: 10 }..{ country: "USA", position: 100 }"#, + "person:{ country: 'USA', position: 10 }..{ country: 'USA', position: 100 }", format!("{}", out) ); } diff --git a/lib/src/sql/strand.rs b/lib/src/sql/strand.rs index e74590b0..70810e96 100644 --- a/lib/src/sql/strand.rs +++ b/lib/src/sql/strand.rs @@ -184,7 +184,7 @@ mod tests { let res = strand(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#""""#, format!("{}", out)); + assert_eq!(r#"''"#, format!("{}", out)); assert_eq!(out, Strand::from("")); } @@ -194,7 +194,7 @@ mod tests { let res = strand(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#""test""#, format!("{}", out)); + assert_eq!(r#"'test'"#, format!("{}", out)); assert_eq!(out, Strand::from("test")); } @@ -204,7 +204,7 @@ mod tests { let res = strand(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#""test""#, format!("{}", out)); + assert_eq!(r#"'test'"#, format!("{}", out)); assert_eq!(out, Strand::from("test")); } @@ -224,7 +224,7 @@ mod tests { let res = strand(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#""te"st""#, format!("{}", out)); + assert_eq!(r#"'te"st'"#, format!("{}", out)); assert_eq!(out, Strand::from(r#"te"st"#)); } @@ -234,7 +234,7 @@ mod tests { let res = strand(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"te\"st\n\tand\u{08}some\u{05d9}\"", format!("{}", out)); + assert_eq!("'te\"st\n\tand\u{08}some\u{05d9}'", format!("{}", out)); assert_eq!(out, Strand::from("te\"st\n\tand\u{08}some\u{05d9}")); } } diff --git a/lib/src/sql/thing.rs b/lib/src/sql/thing.rs index d57f06cc..295f9f24 100644 --- a/lib/src/sql/thing.rs +++ b/lib/src/sql/thing.rs @@ -202,7 +202,7 @@ mod tests { let res = thing(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#"test:{ location: "GBR", year: 2022 }"#, format!("{}", out)); + assert_eq!("test:{ location: 'GBR', year: 2022 }", format!("{}", out)); assert_eq!( out, Thing { @@ -221,7 +221,7 @@ mod tests { let res = thing(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!(r#"test:["GBR", 2022]"#, format!("{}", out)); + assert_eq!("test:['GBR', 2022]", format!("{}", out)); assert_eq!( out, Thing { diff --git a/lib/src/sql/uuid.rs b/lib/src/sql/uuid.rs index 725de7c4..2bfd1d11 100644 --- a/lib/src/sql/uuid.rs +++ b/lib/src/sql/uuid.rs @@ -121,7 +121,7 @@ mod tests { let res = uuid_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"e72bee20-f49b-11ec-b939-0242ac120002\"", format!("{}", out)); + assert_eq!("'e72bee20-f49b-11ec-b939-0242ac120002'", format!("{}", out)); assert_eq!(out, Uuid::from("e72bee20-f49b-11ec-b939-0242ac120002")); } @@ -131,7 +131,7 @@ mod tests { let res = uuid_raw(sql); assert!(res.is_ok()); let out = res.unwrap().1; - assert_eq!("\"b19bc00b-aa98-486c-ae37-c8e1c54295b1\"", format!("{}", out)); + assert_eq!("'b19bc00b-aa98-486c-ae37-c8e1c54295b1'", format!("{}", out)); assert_eq!(out, Uuid::from("b19bc00b-aa98-486c-ae37-c8e1c54295b1")); } } diff --git a/lib/src/sql/version.rs b/lib/src/sql/version.rs index d87946dd..d823f191 100644 --- a/lib/src/sql/version.rs +++ b/lib/src/sql/version.rs @@ -33,6 +33,6 @@ mod tests { assert!(res.is_ok()); let out = res.unwrap().1; assert_eq!(out, Version(Datetime::from("2020-01-01T00:00:00Z"))); - assert_eq!("VERSION \"2020-01-01T00:00:00Z\"", format!("{}", out)); + assert_eq!("VERSION '2020-01-01T00:00:00Z'", format!("{}", out)); } } diff --git a/lib/tests/define.rs b/lib/tests/define.rs index 60495be7..2ce68ea9 100644 --- a/lib/tests/define.rs +++ b/lib/tests/define.rs @@ -258,12 +258,12 @@ async fn define_statement_event_when_event() -> Result<(), Error> { // let tmp = res.remove(0).result?; let val = Value::parse( - "{ - ev: { test: 'DEFINE EVENT test ON user WHEN $event = \"CREATE\" THEN (CREATE activity SET user = $this, value = $after.email, action = $event)' }, + r#"{ + ev: { test: "DEFINE EVENT test ON user WHEN $event = 'CREATE' THEN (CREATE activity SET user = $this, value = $after.email, action = $event)" }, fd: {}, ft: {}, ix: {}, - }", + }"#, ); assert_eq!(tmp, val); // @@ -428,12 +428,12 @@ async fn define_statement_field_value() -> Result<(), Error> { // let tmp = res.remove(0).result?; let val = Value::parse( - "{ + r#"{ ev: {}, - fd: { test: 'DEFINE FIELD test ON user VALUE $value OR \"GBR\"' }, + fd: { test: "DEFINE FIELD test ON user VALUE $value OR 'GBR'" }, ft: {}, ix: {}, - }", + }"#, ); assert_eq!(tmp, val); // @@ -492,12 +492,12 @@ async fn define_statement_field_type_value_assert() -> Result<(), Error> { // let tmp = res.remove(0).result?; let val = Value::parse( - "{ + r#"{ ev: {}, - fd: { test: 'DEFINE FIELD test ON user TYPE string VALUE $value OR \"GBR\" ASSERT $value != NONE AND $value = /[A-Z]{3}/' }, + fd: { test: "DEFINE FIELD test ON user TYPE string VALUE $value OR 'GBR' ASSERT $value != NONE AND $value = /[A-Z]{3}/" }, ft: {}, ix: {}, - }", + }"#, ); assert_eq!(tmp, val); // @@ -688,7 +688,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", with record `user:2`"# + Some(e) if e.to_string() == r#"Database index `test` already contains 'test@surrealdb.com', with record `user:2`"# )); // let tmp = res.remove(0).result; @@ -750,13 +750,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"], with record `user:3`"# + 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"], with record `user:4`"# + Some(e) if e.to_string() == r#"Database index `test` already contains ['tesla', 'test@surrealdb.com'], with record `user:4`"# )); // let tmp = res.remove(0).result; @@ -769,7 +769,7 @@ 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 ["tesla", "test@surrealdb.com"], with record `user:4`"# + Some(e) if e.to_string() == r#"Database index `test` already contains ['tesla', 'test@surrealdb.com'], with record `user:4`"# )); // let tmp = res.remove(0).result; @@ -809,13 +809,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", with record `user:3`"# + 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", with record `user:3`"# + 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?; @@ -863,13 +863,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"], with record `user:3`"# + 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"], with record `user:3`"# + 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?;