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

Function no_cache_mode

http-cache-reqwest/src/test.rs:134–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132 assert!(data.is_some());
133 Ok(())
134}
135
136#[tokio::test]
137async fn max_ttl_applies_to_buffered_responses() -> Result<()> {
138 let mock_server = MockServer::start().await;
139 let m = build_mock(CACHEABLE_PUBLIC, TEST_BODY, 200, 2);
140 let _mock_guard = mock_server.register_as_scoped(m).await;
141 let url = format!("{}/", mock_server.uri());
142 let manager = create_cache_manager();
143
144 let client = ClientBuilder::new(Client::new())
145 .with(Cache(HttpCache {
146 mode: CacheMode::Default,
147 manager: manager.clone(),
148 options: HttpCacheOptions {
149 max_ttl: Some(Duration::ZERO),
150 ..Default::default()
151 },
152 }))
153 .build();
154
155 // A zero maximum TTL still permits storage, but makes the stored policy
156 // immediately stale.
157 let response = client.get(&url).send().await?;
158 assert_eq!(response.bytes().await?, TEST_BODY);
159 let cached =
160 CacheManager::get(&manager, &format!("{}:{}", GET, url_parse(&url)?))
161 .await?;
162 let (cached_response, policy) = cached.expect("response should be stored");
163 assert_eq!(
164 cached_response.headers.get("cache-control").map(String::as_str),
165 Some(CACHEABLE_PUBLIC)

Callers

nothing calls this directly

Calls 6

create_cache_managerFunction · 0.85
buildMethod · 0.80
cloneMethod · 0.80
build_mockFunction · 0.70
CacheClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected