MCPcopy Create free account
hub / github.com/06chaynes/http-cache / quickcache

Function quickcache

http-cache-quickcache/src/test.rs:36–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34
35#[apply(test!)]
36async fn quickcache() -> Result<()> {
37 // Added to test custom Debug impl
38 assert_eq!(
39 format!("{:?}", QuickManager::default()),
40 "QuickManager { cache: \"Cache<String, Arc<Vec<u8>>>\", .. }",
41 );
42 let url = url_parse("http://example.com")?;
43 let manager = Arc::new(QuickManager::default());
44 let http_res = HttpResponse {
45 body: TEST_BODY.to_vec(),
46 headers: Default::default(),
47 status: 200,
48 url: url.clone(),
49 version: HttpVersion::Http11,
50 metadata: None,
51 };
52 let req = http::Request::get("http://example.com").body(())?;
53 let res = http::Response::builder().status(200).body(TEST_BODY.to_vec())?;
54 let policy = CachePolicy::new(&req, &res);
55 CacheManager::put(
56 &*manager,
57 format!("{}:{}", GET, url),
58 http_res.clone(),
59 policy.clone(),
60 )
61 .await?;
62 let data =
63 CacheManager::get(&*manager, &format!("{}:{}", GET, url)).await?;
64 assert!(data.is_some());
65 assert_eq!(data.unwrap().0.body, TEST_BODY);
66 CacheManager::delete(&*manager, &format!("{}:{}", GET, url)).await?;
67 let data =
68 CacheManager::get(&*manager, &format!("{}:{}", GET, url)).await?;
69 assert!(data.is_none());
70 Ok(())
71}
72
73#[tokio::test]
74async fn default_mode() -> Result<()> {

Callers

nothing calls this directly

Calls 4

url_parseFunction · 0.85
cloneMethod · 0.80
bodyMethod · 0.80
statusMethod · 0.80

Tested by

no test coverage detected