Skip to content

Commit

Permalink
Fix tests, replace match with matches!
Browse files Browse the repository at this point in the history
  • Loading branch information
halfmatthalfcat committed Mar 17, 2022
1 parent 5d4a974 commit 35214dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 72 deletions.
1 change: 1 addition & 0 deletions docker/sql_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 6 additions & 36 deletions postgres-protocol/src/types/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,15 @@ 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]
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]
Expand All @@ -212,25 +202,15 @@ 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]
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]
Expand All @@ -250,23 +230,13 @@ 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]
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(_)))
}
36 changes: 0 additions & 36 deletions tokio-postgres/tests/test/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
Expand All @@ -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[]",
&[
Expand All @@ -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",
&[
Expand All @@ -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[]",
&[
Expand All @@ -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",
&[
Expand All @@ -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[]",
&[
Expand Down

0 comments on commit 35214dc

Please sign in to comment.