Skip to content

Commit

Permalink
Add test for specifying both tumbling window kinds -> error.
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Wahl <mwahl@wayfair.com>
  • Loading branch information
Matthias Wahl committed Mar 15, 2021
1 parent 0d1830f commit a2980f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
9 changes: 7 additions & 2 deletions tests/query_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ macro_rules! test_cases {
let err = err.trim();

match to_pipe(&module_path, err_file, &contents) {
Err(Error(ErrorKind::Pipeline(tremor_pipeline::errors::ErrorKind::Script(e)), o)) =>{
Err(Error(ErrorKind::Pipeline(tremor_pipeline::errors::ErrorKind::Script(e)), o)) => {
let e = tremor_script::errors::Error(e, o);
let mut h = Dumb::new();
tremor_script::query::Query::format_error_from_script(&contents, &mut h, &e)?;
Expand All @@ -103,7 +103,11 @@ macro_rules! test_cases {
println!("{}", got);
assert_eq!(err, got);
}
Err(e) =>{
Err(Error(ErrorKind::Pipeline(e), _)) =>{
let got = format!("{}", e);
assert_eq!(err, got, "unexpected error message: {}", got);
}
Err(e) => {
println!("got wrong error: {:?}", e);
assert!(false);
}
Expand Down Expand Up @@ -138,6 +142,7 @@ test_cases!(
pp_embed_unrecognized_token4,
pp_embed_unrecognized_token5,
// INSERT
window_both_settings,
window_group_by_event_in_target,
window_event_in_target,
aggr_arity,
Expand Down
1 change: 1 addition & 0 deletions tests/query_errors/window_both_settings/error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bad window configuration, only one of `size` or `interval` is allowed.
6 changes: 6 additions & 0 deletions tests/query_errors/window_both_settings/query.trickle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define tumbling window both_windows
with
size = 1,
interval = 1
end;
select aggr::stats::count() from in[both_windows] into out;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ onramp:
type: file
config:
source: in.json
sleep_on_done: 2000
sleep_on_done: 2100
close_on_done: true
offramp:
- id: out
Expand Down
4 changes: 2 additions & 2 deletions tremor-pipeline/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ pub(crate) fn window_decl_to_impl<'script>(
)
.into()),
(Some(_), Some(_)) => Err(Error::from(
"Bad window configuration, only one of `size` or `interval` is allowed",
"Bad window configuration, only one of `size` or `interval` is allowed.",
)),
(None, None) => Err(Error::from(
"Bad window configuration, either `size` or `interval` is required",
"Bad window configuration, either `size` or `interval` is required.",
)),
}
}
Expand Down

0 comments on commit a2980f0

Please sign in to comment.