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

Function default_mode

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

Source from the content-addressed store, hash-verified

72
73#[tokio::test]
74async fn default_mode() -> Result<()> {
75 let mock_server = MockServer::start().await;
76 let m = build_mock(CACHEABLE_PUBLIC, TEST_BODY, 200, 1);
77 let _mock_guard = mock_server.register_as_scoped(m).await;
78 let url = format!("{}/", mock_server.uri());
79 let manager = QuickManager::default();
80
81 // Construct reqwest client with cache defaults
82 let client = ClientBuilder::new(Client::new())
83 .with(Cache(HttpCache {
84 mode: CacheMode::Default,
85 manager: manager.clone(),
86 options: HttpCacheOptions::default(),
87 }))
88 .build();
89
90 // Cold pass to load cache
91 client.get(url.clone()).send().await?;
92
93 // Try to load cached object
94 let data =
95 CacheManager::get(&manager, &format!("{}:{}", GET, url_parse(&url)?))
96 .await?;
97 assert!(data.is_some());
98
99 // Hot pass to make sure the expect response was returned
100 let res = client.get(url).send().await?;
101 assert_eq!(res.bytes().await?, TEST_BODY);
102 Ok(())
103}
104
105#[tokio::test]
106async fn default_mode_with_options() -> 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