Fix tests, replace match with matches!

This commit is contained in:
Matt Oliver 2022-03-16 21:20:34 -05:00
parent d9d283e131
commit 6fae6552ec
3 changed files with 7 additions and 72 deletions

View File

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

View File

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

View File

@ -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[]",
&[