test(linux): cover self-test capture payload handling
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled
This commit is contained in:
parent
ba7014468b
commit
95d6eef866
@ -903,3 +903,38 @@ fn process_payload(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod self_test_regressions {
|
||||
use super::*;
|
||||
use std::io::Cursor;
|
||||
|
||||
fn read_test_capture<R: Read>(mut reader: R) -> Result<Vec<u8>, std::io::Error> {
|
||||
let mut bytes = Vec::new();
|
||||
let mut buffer = [0u8; 32 * 1024];
|
||||
loop {
|
||||
match reader.read(&mut buffer) {
|
||||
Ok(0) => break,
|
||||
Ok(read) => bytes.extend_from_slice(&buffer[..read]),
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn self_test_stream_payload_is_preserved_for_capture_processing() {
|
||||
let payload = b"%PDF-1.4\nFieldLens capture self-test\n%%EOF\n";
|
||||
let bytes = read_test_capture(Cursor::new(payload)).expect("read self-test payload");
|
||||
assert_eq!(bytes, payload);
|
||||
assert!(!bytes.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_self_test_stream_stays_empty() {
|
||||
let bytes = read_test_capture(Cursor::new(Vec::<u8>::new()))
|
||||
.expect("read empty self-test payload");
|
||||
assert!(bytes.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user