Create an item with appropriate keys for the given table.
(table_name: &str)
| 398 | |
| 399 | /// Create an item with appropriate keys for the given table. |
| 400 | pub fn create_item(table_name: &str) -> HashMap<String, AttributeValue> { |
| 401 | let unique = Uuid::new_v4().to_string(); |
| 402 | let mut item = HashMap::new(); |
| 403 | |
| 404 | if table_name.starts_with("SimpleKeyString") { |
| 405 | item.insert(HASH_KEY_S.into(), s(&unique)); |
| 406 | } else if table_name.starts_with("CompKeyStringNumber") { |
| 407 | item.insert(HASH_KEY_S.into(), s(&unique)); |
| 408 | item.insert(RANGE_KEY_N.into(), n(unique_range())); |
| 409 | } else if table_name.starts_with("CompKeyBlobNumber") { |
| 410 | item.insert(HASH_KEY_B.into(), b(&unique)); |
| 411 | item.insert(RANGE_KEY_N.into(), n(unique_range())); |
| 412 | } else if table_name.starts_with("CompKeyNumberString") { |
| 413 | item.insert(HASH_KEY_N.into(), n(unique_range())); |
| 414 | item.insert(RANGE_KEY_S.into(), s(&unique)); |
| 415 | } else if table_name.starts_with("CompKeyStringStringGSI") { |
| 416 | item.insert(HASH_KEY_S.into(), s(&unique)); |
| 417 | item.insert(RANGE_KEY_S.into(), s(&format!("range_{unique}"))); |
| 418 | } else { |
| 419 | item.insert(HASH_KEY_S.into(), s(&unique)); |
| 420 | } |
| 421 | |
| 422 | item.insert("str".into(), s(&format!("testValue_{}", &unique[..8]))); |
| 423 | item.insert("num".into(), n(42)); |
| 424 | item |
| 425 | } |
| 426 | |
| 427 | /// Create an item with GSI key attributes. |
| 428 | pub fn create_item_with_gsi(table_name: &str) -> HashMap<String, AttributeValue> { |
no test coverage detected