in src/entrypoints/lambda/dynamodb/model.rs [304:338]
fn test_dynamodb_into_event() {
let ddb_event = get_ddb_event();
let events = ddb_event
.records
.iter()
.map(|r| r.try_into())
.collect::<Result<Vec<Event>, _>>()
.unwrap();
assert_eq!(events.len(), 2);
match &events[0] {
Event::Created { product } => {
assert_eq!(product.id, "101");
assert_eq!(product.name, "new-item");
assert_eq!(product.price, 10.5);
}
_ => {
assert!(false)
}
};
match &events[1] {
Event::Updated { new, old } => {
assert_eq!(new.id, "102");
assert_eq!(new.name, "new-item2");
assert_eq!(new.price, 30.5);
assert_eq!(old.id, "102");
assert_eq!(old.name, "new-item2");
assert_eq!(old.price, 20.5);
}
_ => {
assert!(false)
}
};
}