Skip to content

Commit

Permalink
Problem: custom_serializer test is not checking serialization
Browse files Browse the repository at this point in the history
For all we know, it may still be using CBOR.

Solution: ensure we're getting our custom serialization
  • Loading branch information
yrashk committed Mar 8, 2023
1 parent cd26d68 commit 9153f8f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pgx-tests/src/tests/postgres_type_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ mod tests {
JsonEnumType, JsonType, VarlenaEnumType, VarlenaType,
};
use pgx::prelude::*;
use pgx::PgVarlena;
use pgx::{varsize_any_exhdr, PgVarlena};

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

#[pg_test]
fn custom_serializer() {
let datum = CustomSerialized.into_datum().unwrap();
// Ensure we actually get our custom format, not the default CBOR
unsafe {
let input = datum.cast_mut_ptr();
let varlena = pg_sys::pg_detoast_datum_packed(input as *mut pg_sys::varlena);
let len = varsize_any_exhdr(varlena);
assert_eq!(len, 1);
}
}

#[pg_test]
fn custom_serializer_end_to_end() {
let s = CustomSerialized;
let _ = Spi::get_one_with_args::<CustomSerialized>(
r#"SELECT $1"#,
Expand Down

0 comments on commit 9153f8f

Please sign in to comment.