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

Function test_parse_search_query

chirpstack/src/storage/search.rs:358–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

356
357 #[test]
358 fn test_parse_search_query() {
359 struct Test {
360 input: String,
361 query: String,
362 tags: HashMap<String, String>,
363 }
364
365 let tests = vec![
366 Test {
367 input: "foo bar".into(),
368 query: "foo bar".into(),
369 tags: HashMap::new(),
370 },
371 Test {
372 input: "foo: bar".into(),
373 query: "foo: bar".into(),
374 tags: HashMap::new(),
375 },
376 Test {
377 input: "foo:bar".into(),
378 query: "".into(),
379 tags: [("foo".into(), "bar".into())].iter().cloned().collect(),
380 },
381 Test {
382 input: "test foo:bar".into(),
383 query: "test".into(),
384 tags: [("foo".into(), "bar".into())].iter().cloned().collect(),
385 },
386 Test {
387 input: "test foo:bar alice:bob".into(),
388 query: "test".into(),
389 tags: [("foo".into(), "bar".into()), ("alice".into(), "bob".into())]
390 .iter()
391 .cloned()
392 .collect(),
393 },
394 ];
395
396 for tst in &tests {
397 let (query, tags) = parse_search_query(&tst.input);
398 assert_eq!(tst.query, query);
399 assert_eq!(tst.tags, tags);
400 }
401 }
402
403 fn build_tags(tags: &[(&str, &str)]) -> fields::KeyValue {
404 fields::KeyValue::new(

Callers

nothing calls this directly

Calls 1

parse_search_queryFunction · 0.85

Tested by

no test coverage detected