Skip to content

Commit

Permalink
Add basic test to deadpool-memcached
Browse files Browse the repository at this point in the history
  • Loading branch information
bikeshedder committed Nov 19, 2024
1 parent c64504e commit f6374bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ services:
- rabbitmq.env
volumes:
- rabbitmq-data:/var/lib/rabbitmq

memcached:
image: memcached:1.6
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ jobs:
RABBITMQ_DEFAULT_USER: deadpool
RABBITMQ_DEFAULT_PASS: deadpool
RABBITMQ_DEFAULT_VHOST: deadpool
memcached:
image: memcached:1.6
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
Expand Down
17 changes: 17 additions & 0 deletions memcached/tests/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Basic tests for deadpool-memcached
use deadpool_memcached::{Manager, Pool};

#[tokio::test]
async fn test_set_get() {
let test_key = "test:basic:test_set_get";
let test_value = "answer_42";
let manager = Manager::new("memcached:11211");
let pool = Pool::builder(manager).build().unwrap();
let mut conn = pool.get().await.unwrap();
let _ = conn.delete(test_key).await;
assert_eq!(conn.get(test_key).await.unwrap(), None);
conn.set(test_key, test_value, None, None).await.unwrap();
let value = String::from_utf8(conn.get(test_key).await.unwrap().unwrap().data).unwrap();
assert_eq!(value, test_value);
}

0 comments on commit f6374bb

Please sign in to comment.