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

Function no_cache_mode

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

Source from the content-addressed store, hash-verified

147
148#[tokio::test]
149async fn no_cache_mode() -> Result<()> {
150 let mock_server = MockServer::start().await;
151 let m = build_mock(CACHEABLE_PUBLIC, TEST_BODY, 200, 2);
152 let _mock_guard = mock_server.register_as_scoped(m).await;
153 let url = format!("{}/", mock_server.uri());
154 let manager = QuickManager::default();
155
156 // Construct reqwest client with cache defaults
157 let client = ClientBuilder::new(Client::new())
158 .with(Cache(HttpCache {
159 mode: CacheMode::NoCache,
160 manager: manager.clone(),
161 options: HttpCacheOptions::default(),
162 }))
163 .build();
164
165 // Remote request and should cache
166 client.get(url.clone()).send().await?;
167
168 // Try to load cached object
169 let data = http_cache::CacheManager::get(
170 &manager,
171 &format!("{}:{}", GET, url_parse(&url)?),
172 )
173 .await?;
174 assert!(data.is_some());
175
176 // To verify our endpoint receives the request rather than a cache hit
177 client.get(url).send().await?;
178 Ok(())
179}
180
181#[tokio::test]
182async fn head_request_caching() -> Result<()> {

Callers

nothing calls this directly

Calls 5

buildMethod · 0.80
cloneMethod · 0.80
build_mockFunction · 0.70
CacheClass · 0.50
getMethod · 0.45

Tested by

no test coverage detected