Skip to content

Commit

Permalink
Merge commit 'refs/pull/305/head' of github.com:jmesmon/rust-systemd …
Browse files Browse the repository at this point in the history
…into url
  • Loading branch information
codyps committed May 2, 2024
2 parents 12735f4 + 67a86af commit f977c95
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/journal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn ts() {
}

let mut j = journal::OpenOptions::default().open().unwrap();
log!(log::Level::Info, "rust-systemd test_seek entry");
log!(log::Level::Info, "rust-systemd ts entry");
j.seek(journal::JournalSeek::Head).unwrap();
j.next().unwrap();
let _s = j.timestamp().unwrap();
Expand All @@ -81,13 +81,14 @@ fn test_seek() {
let c1 = j.cursor().unwrap();
let c2 = j.cursor().unwrap();
assert_eq!(c1, c2);

j.seek(journal::JournalSeek::Tail).unwrap();
j.next_entry().unwrap();
let c3 = j.cursor().unwrap();
let valid_cursor = journal::JournalSeek::Cursor { cursor: c3 };
assert!(j.next_entry().unwrap().is_none());

let valid_cursor = journal::JournalSeek::Cursor { cursor: c1 };
j.seek(valid_cursor).unwrap();
let invalid_cursor = journal::JournalSeek::Cursor {
cursor: "".to_string(),
cursor: "invalid".to_string(),
};
assert!(j.seek(invalid_cursor).is_err());
}
Expand All @@ -107,8 +108,10 @@ fn test_simple_match() {

// seek tail
j.seek(journal::JournalSeek::Tail).unwrap();
journal::send(&[&filter, msg]);
j.previous().unwrap();
j.match_add(key, value).unwrap();

journal::send(&[&filter, msg]);
let mut waits = 0;
loop {
if j.next().unwrap() == 0 {
Expand All @@ -134,6 +137,7 @@ fn test_simple_match() {

// check for negative matches
j.seek(journal::JournalSeek::Tail).unwrap();
j.previous().unwrap();
j.match_flush()
.unwrap()
.match_add("NOKEY", "NOVALUE")
Expand Down

0 comments on commit f977c95

Please sign in to comment.