From fb66cfa66563e45a0f0dad3c8fd7dba8a264d346 Mon Sep 17 00:00:00 2001 From: PoiScript Date: Fri, 20 Mar 2020 11:26:13 +0800 Subject: [PATCH] add ui tests for ipnetwork --- tests/ui-tests.rs | 4 +++ tests/ui/postgres/gated/ipnetwork.rs | 9 +++++++ tests/ui/postgres/gated/ipnetwork.stderr | 31 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/ui/postgres/gated/ipnetwork.rs create mode 100644 tests/ui/postgres/gated/ipnetwork.stderr diff --git a/tests/ui-tests.rs b/tests/ui-tests.rs index b83ba0f6..f706e377 100644 --- a/tests/ui-tests.rs +++ b/tests/ui-tests.rs @@ -13,6 +13,10 @@ fn ui_tests() { if cfg!(not(feature = "uuid")) { t.compile_fail("tests/ui/postgres/gated/uuid.rs"); } + + if cfg!(not(feature = "ipnetwork")) { + t.compile_fail("tests/ui/postgres/gated/ipnetwork.rs"); + } } if cfg!(feature = "mysql") { diff --git a/tests/ui/postgres/gated/ipnetwork.rs b/tests/ui/postgres/gated/ipnetwork.rs new file mode 100644 index 00000000..c650c746 --- /dev/null +++ b/tests/ui/postgres/gated/ipnetwork.rs @@ -0,0 +1,9 @@ +fn main() { + let _ = sqlx::query!("select '127.0.0.1'::inet"); + + let _ = sqlx::query!("select '2001:4f8:3:ba::/64'::cidr"); + + let _ = sqlx::query!("select $1::inet", ()); + + let _ = sqlx::query!("select $1::cidr", ()); +} diff --git a/tests/ui/postgres/gated/ipnetwork.stderr b/tests/ui/postgres/gated/ipnetwork.stderr new file mode 100644 index 00000000..1dc4375d --- /dev/null +++ b/tests/ui/postgres/gated/ipnetwork.stderr @@ -0,0 +1,31 @@ +error: optional feature `ipnetwork` required for type INET of column #1 ("inet") + --> $DIR/ipnetwork.rs:2:13 + | +2 | let _ = sqlx::query!("select '127.0.0.1'::inet"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: optional feature `ipnetwork` required for type CIDR of column #1 ("cidr") + --> $DIR/ipnetwork.rs:4:13 + | +4 | let _ = sqlx::query!("select '2001:4f8:3:ba::/64'::cidr"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: optional feature `ipnetwork` required for type INET of param #1 + --> $DIR/ipnetwork.rs:6:13 + | +6 | let _ = sqlx::query!("select $1::inet", ()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: optional feature `ipnetwork` required for type CIDR of param #1 + --> $DIR/ipnetwork.rs:8:13 + | +8 | let _ = sqlx::query!("select $1::cidr", ()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)