about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-10-15T23·52+0200
committerVincent Ambo <tazjin@gmail.com>2017-10-16T00·00+0200
commit6be954393b452275445108098d3ea24af25248b7 (patch)
treeead17a716157b28034f5c5052eaed960745dc457 /src
parentc3cc663ab1eafec38033a845c37d8766b334d321 (diff)
feat(tests): Add a simple send/receive test
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs2
-rw-r--r--src/tests.rs22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 877017e89308..475b2c0f44d2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,7 +56,7 @@ impl Name {
     }
 }
 
-#[derive(Debug)]
+#[derive(Debug, PartialEq)]
 pub struct Message {
     pub data: Vec<u8>,
     pub priority: u32,
diff --git a/src/tests.rs b/src/tests.rs
new file mode 100644
index 000000000000..0018e40dacd3
--- /dev/null
+++ b/src/tests.rs
@@ -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();
+}