MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_http

Function test_http

chirpstack/src/integration/http.rs:212–330  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210
211 #[tokio::test]
212 async fn test_http() {
213 let server = MockServer::start();
214
215 let i = Integration {
216 endpoints: vec![server.url("/")],
217 headers: [("Foo".to_string(), "Bar".to_string())]
218 .iter()
219 .cloned()
220 .collect(),
221 json: true,
222 };
223
224 // uplink event
225 let pl: integration::UplinkEvent = Default::default();
226 let mut mock = server.mock(|when, then| {
227 when.method(POST)
228 .path("/")
229 .query_param("event", "up")
230 .header("Foo", "Bar")
231 .body(serde_json::to_string(&pl).unwrap());
232
233 then.status(200);
234 });
235
236 i.uplink_event(&HashMap::new(), &pl).await.unwrap();
237 mock.assert();
238 mock.delete();
239
240 // join event
241 let pl: integration::JoinEvent = Default::default();
242 let mut mock = server.mock(|when, then| {
243 when.method(POST)
244 .path("/")
245 .query_param("event", "join")
246 .header("Foo", "Bar")
247 .body(serde_json::to_string(&pl).unwrap());
248
249 then.status(200);
250 });
251
252 i.join_event(&HashMap::new(), &pl).await.unwrap();
253 mock.assert();
254 mock.delete();
255
256 // ack event
257 let pl: integration::AckEvent = Default::default();
258 let mut mock = server.mock(|when, then| {
259 when.method(POST)
260 .path("/")
261 .query_param("event", "ack")
262 .header("Foo", "Bar")
263 .body(serde_json::to_string(&pl).unwrap());
264
265 then.status(200);
266 });
267 i.ack_event(&HashMap::new(), &pl).await.unwrap();
268 mock.assert();
269 mock.delete();

Callers

nothing calls this directly

Calls 13

startFunction · 0.85
iterMethod · 0.80
to_stringMethod · 0.80
unwrapMethod · 0.80
statusMethod · 0.80
uplink_eventMethod · 0.45
deleteMethod · 0.45
join_eventMethod · 0.45
ack_eventMethod · 0.45
txack_eventMethod · 0.45
log_eventMethod · 0.45
status_eventMethod · 0.45

Tested by

no test coverage detected