From 38b749bea26b08c20f00f2719690e9357287ca09 Mon Sep 17 00:00:00 2001 From: Jubilee <46493976+workingjubilee@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:11:23 -0800 Subject: [PATCH] Remove flaky `serde_serialize_array` todo test (#1503) This test emits a dependency's source code path in the snapshot, which makes it prone to breaking inaccurately because that is versioned. This complicates contributions unduly, so remove it. --- pgrx-tests/tests/todo/array-serialize-json.rs | 32 ------------------- .../tests/todo/array-serialize-json.stderr | 22 ------------- 2 files changed, 54 deletions(-) delete mode 100644 pgrx-tests/tests/todo/array-serialize-json.rs delete mode 100644 pgrx-tests/tests/todo/array-serialize-json.stderr diff --git a/pgrx-tests/tests/todo/array-serialize-json.rs b/pgrx-tests/tests/todo/array-serialize-json.rs deleted file mode 100644 index 1ab1fe220..000000000 --- a/pgrx-tests/tests/todo/array-serialize-json.rs +++ /dev/null @@ -1,32 +0,0 @@ -use pgrx::prelude::*; -use pgrx::datum::Json; -use serde_json::json; - -fn main() {} - -// TODO: fix this test by fixing serde impls for `Array<'a, &'a str> -> Json` -#[pg_extern] -fn serde_serialize_array<'dat>(values: Array<'dat, &'dat str>) -> Json { - Json(json! { { "values": values } }) -} - -#[pgrx::pg_schema] -mod tests { - #[allow(unused_imports)] - use crate as pgrx_tests; - - use pgrx::prelude::*; - use pgrx::Json; - use serde_json::json; - - // TODO: fix this test by redesigning SPI. - #[pg_test] - fn test_serde_serialize_array() -> Result<(), pgrx::spi::Error> { - let json = Spi::get_one::( - "SELECT serde_serialize_array(ARRAY['one', null, 'two', 'three'])", - )? - .expect("returned json was null"); - assert_eq!(json.0, json! {{"values": ["one", null, "two", "three"]}}); - Ok(()) - } -} diff --git a/pgrx-tests/tests/todo/array-serialize-json.stderr b/pgrx-tests/tests/todo/array-serialize-json.stderr deleted file mode 100644 index 015c3fbd0..000000000 --- a/pgrx-tests/tests/todo/array-serialize-json.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> tests/todo/array-serialize-json.rs:10:10 - | -9 | fn serde_serialize_array<'dat>(values: Array<'dat, &'dat str>) -> Json { - | ---- ------ `values` is a reference that is only valid in the function body - | | - | lifetime `'dat` defined here -10 | Json(json! { { "values": values } }) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `values` escapes the function body here - | argument requires that `'dat` must outlive `'static` - | - = note: requirement occurs because of the type `pgrx::Array<'_, &str>`, which makes the generic argument `&str` invariant - = note: the struct `pgrx::Array<'mcx, T>` is invariant over the parameter `T` - = help: see for more information about variance -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $CARGO/serde_json-1.0.111/src/value/mod.rs - | - | T: Serialize, - | ^^^^^^^^^ - = note: this error originates in the macro `json_internal` which comes from the expansion of the macro `json` (in Nightly builds, run with -Z macro-backtrace for more info)