Skip to content

Commit

Permalink
Fixups of issues left from #1837 (#1843)
Browse files Browse the repository at this point in the history
Fixes issues left from #1837, but nothing critical.

The problem with `unreachable!` in tests is that it requires to have a
non-empty `expected` in the `#[should_panic]` attribute. So we provide a
message to verify that panicking happens for the right reason.
  • Loading branch information
YohDeadfall authored Sep 6, 2024
1 parent 5a1151e commit 922a43f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pgrx-tests/src/tests/spi_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,19 @@ mod tests {
}

#[pg_test]
#[should_panic]
#[should_panic(expected = "PreparedStatementArgumentMismatch { expected: 1, got: 0 }")]
fn test_cursor_prepared_statement_panics_none_args() -> Result<(), pgrx::spi::Error> {
test_cursor_prepared_statement_panics_impl(None)
}

#[pg_test]
#[should_panic]
#[should_panic(expected = "PreparedStatementArgumentMismatch { expected: 1, got: 0 }")]
fn test_cursor_prepared_statement_panics_less_args() -> Result<(), pgrx::spi::Error> {
test_cursor_prepared_statement_panics_impl(Some([].to_vec()))
}

#[pg_test]
#[should_panic]
#[should_panic(expected = "PreparedStatementArgumentMismatch { expected: 1, got: 2 }")]
fn test_cursor_prepared_statement_panics_more_args() -> Result<(), pgrx::spi::Error> {
test_cursor_prepared_statement_panics_impl(Some([None, None].to_vec()))
}
Expand Down Expand Up @@ -570,7 +570,6 @@ mod tests {
}

#[pg_test]
#[allow(deprecated)]
fn can_return_borrowed_str() -> Result<(), Box<dyn Error>> {
let res = Spi::connect(|c| {
let mut cursor = c.open_cursor("SELECT 'hello' FROM generate_series(1, 10000)", None);
Expand Down

0 comments on commit 922a43f

Please sign in to comment.