mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	test correct primary key inference
This commit is contained in:
		| @@ -497,6 +497,7 @@ mod test { | ||||
|     use super::*; | ||||
|  | ||||
|     mod compute_primary_key { | ||||
|  | ||||
|         use super::{compute_primary_key_pair, FieldsIdsMap}; | ||||
|  | ||||
|         #[test] | ||||
| @@ -537,5 +538,27 @@ mod test { | ||||
|             assert!(result.is_err()); | ||||
|             assert_eq!(fields_map.len(), 0); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     mod primary_key_inference { | ||||
|         use bimap::BiHashMap; | ||||
|  | ||||
|         use crate::update::index_documents::transform::find_primary_key; | ||||
|  | ||||
|         #[test] | ||||
|         fn primary_key_infered_on_first_field() { | ||||
|             // We run the test multiple times to change the order in which the fields are iterated upon. | ||||
|             for _ in 1..50 { | ||||
|                 let mut map = BiHashMap::new(); | ||||
|                 map.insert(1, "fakeId".to_string()); | ||||
|                 map.insert(2, "fakeId".to_string()); | ||||
|                 map.insert(3, "fakeId".to_string()); | ||||
|                 map.insert(4, "fakeId".to_string()); | ||||
|                 map.insert(0, "realId".to_string()); | ||||
|  | ||||
|                 assert_eq!(find_primary_key(&map), Some("realId")); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user