Skip to content

Commit

Permalink
Testing VolatileStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
castelao committed Sep 30, 2023
1 parent 3681803 commit 0c021f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sqlx = { workspace = true, optional = true }
tempfile = { workspace = true }

[dev-dependencies]
tokio = { workspace = true, features = ["rt-multi-thread"] }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }

[features]
sqlite = ["dep:sqlx"]
26 changes: 26 additions & 0 deletions crates/storage/src/inmemory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,29 @@ impl VolatileStorage {
.push(msg);
}
}

#[cfg(test)]
mod test_volatile {
use super::VolatileStorage;
use directip;

fn sample() -> directip::Message {
let msg = directip::mt::MTMessage::from_reader(
[
0x01, 0x00, 0x1c, 0x44, 0x00, 0x19, 0x00, 0x00, 0x27, 0x0f, 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf5,
]
.as_slice(),
);
directip::Message::MT(msg.unwrap())
}

#[tokio::test]
async fn volatile() {
let storage = VolatileStorage::connect().unwrap();
storage.save(sample()).await;

assert_eq!(storage.data.read().unwrap().len(), 1);
}
}

0 comments on commit 0c021f6

Please sign in to comment.