use dynamodb_facade::{
AttributeDefinition, CompositeKeySchema, KeySchema, SimpleKeySchema, StringAttribute,
TableDefinition,
};
dynamodb_facade::attribute_definitions! {
TPk { "TPK": StringAttribute }
TSk { "TSK": StringAttribute }
}
dynamodb_facade::table_definitions! {
CompositeTestTable {
type PartitionKey = TPk;
type SortKey = TSk;
fn table_name() -> String { "composite".to_owned() }
}
SimpleTestTable {
type PartitionKey = TPk;
fn table_name() -> String { "simple".to_owned() }
}
}
#[test]
fn test_table_definitions_composite_and_simple_wiring() {
assert_eq!(CompositeTestTable::table_name(), "composite");
assert_eq!(SimpleTestTable::table_name(), "simple");
type CompositeKS = <CompositeTestTable as TableDefinition>::KeySchema;
fn assert_composite<KS: CompositeKeySchema>() {}
assert_composite::<CompositeKS>();
assert_eq!(<CompositeKS as KeySchema>::PartitionKey::NAME, "TPK");
assert_eq!(<CompositeKS as CompositeKeySchema>::SortKey::NAME, "TSK");
type SimpleKS = <SimpleTestTable as TableDefinition>::KeySchema;
fn assert_simple<KS: SimpleKeySchema>() {}
assert_simple::<SimpleKS>();
assert_eq!(<SimpleKS as KeySchema>::PartitionKey::NAME, "TPK");
}