Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Nov 1, 2023
1 parent 89dfb13 commit 680875b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plrust-tests/src/trusted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,16 @@ mod tests {

#[pg_test]
#[search_path(@extschema@)]
#[should_panic = "environment variable `PATH` not defined at compile time."]
#[should_panic = "environment variable `FOOBAR` not defined at compile time"]
#[cfg(feature = "trusted")]
fn plrust_block_env() -> spi::Result<()> {
let definition = r#"
CREATE FUNCTION get_path() RETURNS text AS $$
let path = env!("PATH");
Ok(Some(path.to_string()))
CREATE FUNCTION get_foobar() RETURNS text AS $$
let foo = env!("FOOBAR");
Ok(Some(foo.to_string()))
$$ LANGUAGE plrust;
"#;
std::env::set_var("FOOBAR", "1");
Spi::run(definition)
}

Expand All @@ -208,12 +209,13 @@ mod tests {
#[cfg(feature = "trusted")]
fn plrust_block_option_env() -> spi::Result<()> {
let definition = r#"
CREATE FUNCTION try_get_path() RETURNS text AS $$
let v = option_env!("PATH")
CREATE FUNCTION try_get_foobar2() RETURNS text AS $$
let v = option_env!("FOOBAR2")
.expect("the `option_env` macro always returns `None` in the PL/Rust user function");
Ok(Some(v.to_string()))
$$ LANGUAGE plrust;
"#;
std::env::set_var("FOOBAR2", "1");
Spi::run(definition)
}

Expand Down

0 comments on commit 680875b

Please sign in to comment.