suggest_command.rs 872 B

123456789101112131415161718192021222324252627282930313233343536
  1. mod common;
  2. use common::*;
  3. const COLLECTION: &str = "Search";
  4. #[test]
  5. fn should_suggest_nearest_word() {
  6. let bucket = "suggest_nearest";
  7. let title = "Sweet Teriyaki Beef Skewers";
  8. let dest = Dest::col_buc(COLLECTION, bucket);
  9. let ingest_channel = ingest_start();
  10. ingest_channel
  11. .push(PushRequest::new(dest.clone().obj("1"), title))
  12. .unwrap();
  13. consolidate();
  14. let pairs = [
  15. ("Sweat", "sweet"),
  16. ("teriaki", "teriyaki"),
  17. ("Beff", "beef"),
  18. ("skwers", "skewers"),
  19. ];
  20. let search_channel = search_start();
  21. for (input, expected) in pairs {
  22. match search_channel.suggest(SuggestRequest::new(dest.clone(), input)) {
  23. Ok(object_ids) => assert_eq!(object_ids, vec![expected]),
  24. Err(_) => unreachable!(),
  25. }
  26. }
  27. flush_bucket(COLLECTION, bucket);
  28. }