feat(tests): Add a simple send/receive test
This commit is contained in:
parent
c3cc663ab1
commit
6be954393b
2 changed files with 23 additions and 1 deletions
|
@ -56,7 +56,7 @@ impl Name {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
pub priority: u32,
|
pub priority: u32,
|
||||||
|
|
22
src/tests.rs
Normal file
22
src/tests.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_open_delete() {
|
||||||
|
// Simple test with default queue settings
|
||||||
|
let name = Name::new("/test-queue").unwrap();
|
||||||
|
let queue = Queue::open_or_create(name)
|
||||||
|
.expect("Opening queue failed");
|
||||||
|
|
||||||
|
let message = Message {
|
||||||
|
data: "test-message".as_bytes().to_vec(),
|
||||||
|
priority: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
queue.send(&message).expect("message sending failed");
|
||||||
|
|
||||||
|
let result = queue.receive().expect("message receiving failed");
|
||||||
|
|
||||||
|
assert_eq!(message, result);
|
||||||
|
|
||||||
|
queue.delete();
|
||||||
|
}
|
Loading…
Reference in a new issue