MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / start_http

Function start_http

nodedb/tests/http_query.rs:26–59  ·  view source on GitHub ↗
(auth_mode: AuthMode)

Source from the content-addressed store, hash-verified

24}
25
26async fn start_http(auth_mode: AuthMode) -> TestServer {
27 let dir = tempfile::tempdir().expect("tempdir");
28 let wal =
29 Arc::new(WalManager::open_for_testing(&dir.path().join("query.wal")).expect("open wal"));
30 let (dispatcher, _data_sides) = Dispatcher::new(1, 64);
31 let shared = SharedState::new(dispatcher, wal);
32
33 let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
34 .await
35 .expect("bind");
36 let local_addr = listener.local_addr().expect("local addr");
37
38 let (bus, _) = nodedb::control::shutdown::ShutdownBus::new(Arc::clone(&shared.shutdown));
39 let shared_http = Arc::clone(&shared);
40 let handle = tokio::spawn(async move {
41 nodedb::control::server::http::server::run_with_listener(
42 listener,
43 shared_http,
44 auth_mode,
45 None,
46 bus,
47 )
48 .await
49 .ok();
50 });
51
52 tokio::time::sleep(Duration::from_millis(40)).await;
53
54 TestServer {
55 local_addr,
56 _server: handle,
57 _dir: dir,
58 }
59}
60
61// ─── /v1/query — auth ────────────────────────────────────────────────────────
62

Calls 7

run_with_listenerFunction · 0.85
joinMethod · 0.80
spawnFunction · 0.50
expectMethod · 0.45
pathMethod · 0.45
local_addrMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected