1- use cryptonamo:: { Decryptable , Encryptable , EncryptedTable , Searchable } ;
1+ use cryptonamo:: { Encryptable , EncryptedTable } ;
2+ use cryptonamo_derive:: { Decryptable , Searchable } ;
23use itertools:: Itertools ;
34use serial_test:: serial;
45use std:: future:: Future ;
56
7+ mod common;
8+
69#[ derive( Encryptable , Decryptable , Searchable , Debug , PartialEq , Ord , PartialOrd , Eq ) ]
710#[ cryptonamo( sort_key_prefix = "user" ) ]
811pub struct User {
@@ -23,7 +26,7 @@ pub struct User {
2326}
2427
2528impl User {
26- fn new ( email : impl Into < String > , name : impl Into < String > , tag : impl Into < String > ) -> Self {
29+ pub fn new ( email : impl Into < String > , name : impl Into < String > , tag : impl Into < String > ) -> Self {
2730 Self {
2831 name : name. into ( ) ,
2932 email : email. into ( ) ,
@@ -41,7 +44,11 @@ async fn run_test<F: Future<Output = ()>>(mut f: impl FnMut(EncryptedTable) -> F
4144
4245 let client = aws_sdk_dynamodb:: Client :: new ( & config) ;
4346
44- let table = EncryptedTable :: init ( client, "users" )
47+ let table_name = "test-users" ;
48+
49+ common:: create_table ( & client, table_name) . await ;
50+
51+ let table = EncryptedTable :: init ( client, table_name)
4552 . await
4653 . expect ( "Failed to init table" ) ;
4754
@@ -131,7 +138,10 @@ async fn test_query_compound() {
131138#[ serial]
132139async fn test_get_by_partition_key ( ) {
133140 run_test ( |table| async move {
134- let res
: Option < User > = table
. get ( "[email protected] " ) . await . expect ( "Failed to send" ) ; 141+ let res: Option < User > = table
142+ 143+ . await
144+ . expect ( "Failed to send" ) ;
135145 assert_eq ! (
136146 res,
137147 Some ( User :: new
( "[email protected] " , "Dan Draper" , "blue" ) ) @@ -145,12 +155,12 @@ async fn test_get_by_partition_key() {
145155async fn test_delete ( ) {
146156 run_test ( |table| async move {
147157 table
148- . delete :: < User > ( "[email protected] " , User :: type_name ( ) ) 158+ . delete :: < User > ( "[email protected] " , None ) 149159 . await
150160 . expect ( "Failed to send" ) ;
151161
152162 let res = table
153- 163+ . get :: < User > ( "[email protected] " , None ) 154164 . await
155165 . expect ( "Failed to send" ) ;
156166 assert_eq ! ( res, None ) ;
0 commit comments