Skip to content

Commit 9153f8f

Browse files
committed
Problem: custom_serializer test is not checking serialization
For all we know, it may still be using CBOR. Solution: ensure we're getting our custom serialization
1 parent cd26d68 commit 9153f8f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pgx-tests/src/tests/postgres_type_tests.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ mod tests {
184184
JsonEnumType, JsonType, VarlenaEnumType, VarlenaType,
185185
};
186186
use pgx::prelude::*;
187-
use pgx::PgVarlena;
187+
use pgx::{varsize_any_exhdr, PgVarlena};
188188

189189
#[pg_test]
190190
fn test_mytype() -> Result<(), pgx::spi::Error> {
@@ -277,6 +277,18 @@ mod tests {
277277

278278
#[pg_test]
279279
fn custom_serializer() {
280+
let datum = CustomSerialized.into_datum().unwrap();
281+
// Ensure we actually get our custom format, not the default CBOR
282+
unsafe {
283+
let input = datum.cast_mut_ptr();
284+
let varlena = pg_sys::pg_detoast_datum_packed(input as *mut pg_sys::varlena);
285+
let len = varsize_any_exhdr(varlena);
286+
assert_eq!(len, 1);
287+
}
288+
}
289+
290+
#[pg_test]
291+
fn custom_serializer_end_to_end() {
280292
let s = CustomSerialized;
281293
let _ = Spi::get_one_with_args::<CustomSerialized>(
282294
r#"SELECT $1"#,

0 commit comments

Comments
 (0)