diff --git a/docker/sql_setup.sh b/docker/sql_setup.sh index 422dcbda9..0315ac805 100755 --- a/docker/sql_setup.sh +++ b/docker/sql_setup.sh @@ -96,4 +96,5 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL CREATE ROLE ssl_user LOGIN; CREATE EXTENSION hstore; CREATE EXTENSION citext; + CREATE EXTENSION ltree; EOSQL diff --git a/postgres-protocol/src/types/test.rs b/postgres-protocol/src/types/test.rs index 1ce49b66f..6f1851fc2 100644 --- a/postgres-protocol/src/types/test.rs +++ b/postgres-protocol/src/types/test.rs @@ -174,12 +174,7 @@ fn ltree_str() { let mut query = vec![1u8]; query.extend_from_slice("A.B.C".as_bytes()); - let success = match ltree_from_sql(query.as_slice()) { - Ok(_) => true, - _ => false, - }; - - assert!(success) + assert!(matches!(ltree_from_sql(query.as_slice()), Ok(_))) } #[test] @@ -187,12 +182,7 @@ fn ltree_wrong_version() { let mut query = vec![2u8]; query.extend_from_slice("A.B.C".as_bytes()); - let success = match ltree_from_sql(query.as_slice()) { - Err(_) => true, - _ => false, - }; - - assert!(success) + assert!(matches!(ltree_from_sql(query.as_slice()), Err(_))) } #[test] @@ -212,12 +202,7 @@ fn lquery_str() { let mut query = vec![1u8]; query.extend_from_slice("A.B.C".as_bytes()); - let success = match lquery_from_sql(query.as_slice()) { - Ok(_) => true, - _ => false, - }; - - assert!(success) + assert!(matches!(lquery_from_sql(query.as_slice()), Ok(_))) } #[test] @@ -225,12 +210,7 @@ fn lquery_wrong_version() { let mut query = vec![2u8]; query.extend_from_slice("A.B.C".as_bytes()); - let success = match lquery_from_sql(query.as_slice()) { - Err(_) => true, - _ => false, - }; - - assert!(success) + assert!(matches!(lquery_from_sql(query.as_slice()), Err(_))) } #[test] @@ -250,12 +230,7 @@ fn ltxtquery_str() { let mut query = vec![1u8]; query.extend_from_slice("a & b*".as_bytes()); - let success = match ltree_from_sql(query.as_slice()) { - Ok(_) => true, - _ => false, - }; - - assert!(success) + assert!(matches!(ltree_from_sql(query.as_slice()), Ok(_))) } #[test] @@ -263,10 +238,5 @@ fn ltxtquery_wrong_version() { let mut query = vec![2u8]; query.extend_from_slice("a & b*".as_bytes()); - let success = match ltree_from_sql(query.as_slice()) { - Err(_) => true, - _ => false, - }; - - assert!(success) + assert!(matches!(ltree_from_sql(query.as_slice()), Err(_))) } diff --git a/tokio-postgres/tests/test/types/mod.rs b/tokio-postgres/tests/test/types/mod.rs index f69932e55..de700d791 100644 --- a/tokio-postgres/tests/test/types/mod.rs +++ b/tokio-postgres/tests/test/types/mod.rs @@ -651,12 +651,6 @@ async fn inet() { #[tokio::test] async fn ltree() { - let client = connect("user=postgres").await; - client - .execute("CREATE EXTENSION IF NOT EXISTS ltree;", &[]) - .await - .unwrap(); - test_type( "ltree", &[(Some("b.c.d".to_owned()), "'b.c.d'"), (None, "NULL")], @@ -666,12 +660,6 @@ async fn ltree() { #[tokio::test] async fn ltree_any() { - let client = connect("user=postgres").await; - client - .execute("CREATE EXTENSION IF NOT EXISTS ltree;", &[]) - .await - .unwrap(); - test_type( "ltree[]", &[ @@ -689,12 +677,6 @@ async fn ltree_any() { #[tokio::test] async fn lquery() { - let client = connect("user=postgres").await; - client - .execute("CREATE EXTENSION IF NOT EXISTS ltree;", &[]) - .await - .unwrap(); - test_type( "lquery", &[ @@ -709,12 +691,6 @@ async fn lquery() { #[tokio::test] async fn lquery_any() { - let client = connect("user=postgres").await; - client - .execute("CREATE EXTENSION IF NOT EXISTS ltree;", &[]) - .await - .unwrap(); - test_type( "lquery[]", &[ @@ -732,12 +708,6 @@ async fn lquery_any() { #[tokio::test] async fn ltxtquery() { - let client = connect("user=postgres").await; - client - .execute("CREATE EXTENSION IF NOT EXISTS ltree;", &[]) - .await - .unwrap(); - test_type( "ltxtquery", &[ @@ -751,12 +721,6 @@ async fn ltxtquery() { #[tokio::test] async fn ltxtquery_any() { - let client = connect("user=postgres").await; - client - .execute("CREATE EXTENSION IF NOT EXISTS ltree;", &[]) - .await - .unwrap(); - test_type( "ltxtquery[]", &[