feat(tests): Add a simple send/receive test

This commit is contained in:
Vincent Ambo 2017-10-16 01:52:56 +02:00
parent c3cc663ab1
commit 6be954393b
2 changed files with 23 additions and 1 deletions

View file

@ -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
View 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();
}