Details
Details
- Reviewers
bartek marcin - Commits
- rCOMMf7ba3bbe5382: [Tunnelbroker] implement setting device token
Execute following tests:
#[tokio::test] async fn test_setting_device_token() { let aws_config = config::load_aws_config().await; let db_client = database::DatabaseClient::new(&aws_config); let device_token: &str = "token"; let device_id: &str = "id1"; db_client .set_device_token(device_id, device_token) .await .unwrap(); let db_device_token = db_client .get_device_token(device_id) .await .unwrap() .unwrap(); assert_eq!(db_device_token, device_token); let updated_device_token: &str = "updated_token"; let device_id: &str = "id1"; db_client .set_device_token(device_id, updated_device_token) .await .unwrap(); let db_device_token = db_client .get_device_token(device_id) .await .unwrap() .unwrap(); assert_eq!(db_device_token, updated_device_token); } #[tokio::test] async fn test_removing_device_token() { let aws_config = config::load_aws_config().await; let db_client = database::DatabaseClient::new(&aws_config); let device_token: &str = "token"; let device_id: &str = "id1"; db_client .set_device_token(device_id, device_token) .await .unwrap(); let db_device_token = db_client .get_device_token(device_id) .await .unwrap() .unwrap(); assert_eq!(db_device_token, device_token); db_client.remove_device_token(device_id).await.expect(""); let db_device_token = db_client.get_device_token(device_id).await.unwrap(); assert_eq!(db_device_token, None); } #[tokio::test] async fn test_device_token_being_unique() { let aws_config = config::load_aws_config().await; let db_client = database::DatabaseClient::new(&aws_config); let device_token: &str = "token"; let device_id_1: &str = "id1"; let device_id_2: &str = "id2"; db_client .set_device_token(device_id_1, device_token) .await .unwrap(); db_client .set_device_token(device_id_2, device_token) .await .unwrap(); let db_device_token_1 = db_client.get_device_token(device_id_1).await.unwrap(); assert_eq!(db_device_token_1, None); let db_device_token_2 = db_client .get_device_token(device_id_2) .await .unwrap() .unwrap(); assert_eq!(db_device_token_2, device_token); }
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
services/tunnelbroker/src/database/mod.rs | ||
---|---|---|
192–196 ↗ | (On Diff #41577) | I guess we have some leftovers in existing code, but the preferred way is to use expression_attribute_names |
207–212 ↗ | (On Diff #41577) |
|
services/tunnelbroker/src/database/mod.rs | ||
---|---|---|
209–210 ↗ | (On Diff #41577) | One more note - put_item() replaces item with given primary key device_id so we can optimize it not to remove it here unnecessarily. |