Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
larsw committed Jan 4, 2024
1 parent 2aa34df commit 1fc197c
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pgrx::prelude::*;
use accumulo_access::check_authorization;

pgrx::pg_module_magic!();
pg_module_magic!();

#[pg_extern]
fn accumulo_check_authorization(expression: &str, tokens: pgrx::Array<String>) -> bool {
Expand All @@ -21,18 +21,21 @@ mod tests {
use pgrx::prelude::*;

#[pg_test]
fn test_hello_accumulo_access_pg() {
fn test_accumulo_check_authorization() {
let expression = "label1 & label5 & (label2 | \"label 🕺\")";
let tokens = &Vec::from([
String::from("label1"),
String::from("label5"),
String::from("label 🕺"),
]);
let tokens = pgrx::Array::from_vec(tokens);
assert_eq!(
true,
crate::accumulo_check_authorization(expression, tokens)
);
let datum = vec![
"label1".to_string(),
"label5".to_string(),
"label 🕺".to_string()
].into_datum().unwrap();

unsafe {
let tokens = pgrx::Array::<String>::from_datum(datum, false).unwrap();
assert_eq!(
true,
crate::accumulo_check_authorization(expression, tokens)
);
}
}
}

Expand Down

0 comments on commit 1fc197c

Please sign in to comment.