diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 737bba9..eb265ce 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -66,3 +66,6 @@ services: - rabbitmq.env volumes: - rabbitmq-data:/var/lib/rabbitmq + + memcached: + image: memcached:1.6 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a853a5c..ea9c430 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/memcached/tests/basic.rs b/memcached/tests/basic.rs new file mode 100644 index 0000000..2ba1357 --- /dev/null +++ b/memcached/tests/basic.rs @@ -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); +}