Skip to content

Commit

Permalink
Some test cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
  • Loading branch information
Licenser committed Nov 9, 2020
1 parent 96ced18 commit 072afb6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ impl Preprocessor for ExtractIngresTs {
*ingest_ns = Cursor::new(data).read_u64::<BigEndian>()?;
Ok(vec![d.to_vec()])
} else {
Err(Error::from(
"Extract Ingest Ts Preprocessor provided with too little data (< 8 byte)",
))
Err(Error::from("Extract Ingest Ts Preprocessor: < 8 byte"))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/preprocessor/lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ impl Preprocessor for Lines {
// AND if the preprocessor has memory of line fragment from earlier,
// reconstruct the first event fully (by adding the buffer contents to it)

// FIXME: what is going on here?
if (last_event.is_empty() || !events.is_empty()) && !self.buffer.is_empty() {
// ALLOW: this is going to be fixed as part of #575
self.complete_fragment(&mut events[0])?;
}

Expand Down
6 changes: 2 additions & 4 deletions tremor-influx/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ fn write_substr<W: Write, I: SliceIndex<[u8], Output = [u8]>>(
data: &[u8],
r: I,
) -> std::io::Result<()> {
use std::io;
if let Some(s) = data.get(r) {
writer.write_all(s)
} else {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Nothing to write",
))
Err(io::Error::new(io::ErrorKind::Other, "Nothing to write"))
}
}
40 changes: 40 additions & 0 deletions tremor-script/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,3 +1751,43 @@ fn replace_last_shadow_use<'script>(replace_idx: usize, expr: Expr<'script>) ->
fn shadow_name(id: usize) -> String {
format!(" __SHADOW {}__ ", id)
}

#[cfg(test)]
mod test {
use simd_json::BorrowedValue;

fn v(s: &'static str) -> super::ImutExprInt<'static> {
super::ImutExprInt::Literal(super::Literal {
mid: 0,
value: BorrowedValue::from(s),
})
}
#[test]
fn record() {
let f1 = super::Field {
mid: 0,
name: v("snot"),
value: v("badger"),
};
let f2 = super::Field {
mid: 0,
name: v("badger"),
value: v("snot"),
};

let r = super::Record {
mid: 0,
fields: vec![f1, f2],
};

assert_eq!(r.get("snot"), Some(&v("badger")));
assert_eq!(r.get("nots"), None);

assert_eq!(
r.get_literal("badger")
.and_then(simd_json::prelude::ValueTrait::as_str),
Some("badger")
);
assert_eq!(r.get("adgerb"), None);
}
}

0 comments on commit 072afb6

Please sign in to comment.