Skip to content

Commit

Permalink
Add tests to parse all arguments in extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
shanretoo committed May 24, 2024
1 parent a41f650 commit 4871d9d
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/parse/text/simple_extensions/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ impl ArgumentsItem {
Some(s) if s.is_empty() => {
Err(ArgumentsItemError::EmptyOptionalField("name".to_string()))
}
_ => Ok(name),
// _ => Ok(name),
_ => Err(ArgumentsItemError::EmptyOptionalField("name".to_string())),
}
}

Expand Down Expand Up @@ -593,4 +594,41 @@ mod tests {
_ => unreachable!(),
}
}

#[cfg(feature = "extensions")]
#[test]
fn parse_extensions() {
use crate::extensions::EXTENSIONS;
use crate::parse::context::tests::Context;

macro_rules! parse_arguments {
($url:expr, $fns:expr) => {
$fns.iter().for_each(|f| {
f.impls
.iter()
.filter_map(|i| i.args.as_ref())
.flat_map(|a| &a.0)
.for_each(|item| {
item.clone()
.parse(&mut Context::default())
.unwrap_or_else(|err| {
panic!(
"found an invalid argument: {}, (url: {}, function: {}, arg: {:?})",
err,
$url.to_string(),
f.name,
item
);
});
})
});
};
}

EXTENSIONS.iter().for_each(|(url, ext)| {
parse_arguments!(url, ext.scalar_functions);
parse_arguments!(url, ext.aggregate_functions);
parse_arguments!(url, ext.window_functions);
});
}
}

0 comments on commit 4871d9d

Please sign in to comment.