77//! Run with: cargo run --example file_tracing --features "tokio tracing"
88//! --release
99
10- use std:: { collections :: HashMap , time:: Instant } ;
10+ use std:: time:: Instant ;
1111
1212use oo7:: file:: Keyring ;
1313use tempfile:: tempdir;
@@ -68,7 +68,7 @@ async fn test_keyring_lifecycle() -> oo7::Result<()> {
6868 keyring
6969 . create_item (
7070 "Test Item" ,
71- & HashMap :: from ( [ ( "app" , "test" ) , ( "user" , "alice" ) ] ) ,
71+ & [ ( "app" , "test" ) , ( "user" , "alice" ) ] ,
7272 "my-secret-password" ,
7373 false ,
7474 )
@@ -85,9 +85,7 @@ async fn test_keyring_lifecycle() -> oo7::Result<()> {
8585
8686 // Measure search
8787 let start = Instant :: now ( ) ;
88- let items = keyring
89- . search_items ( & HashMap :: from ( [ ( "app" , "test" ) ] ) )
90- . await ?;
88+ let items = keyring. search_items ( & [ ( "app" , "test" ) ] ) . await ?;
9189 let search_time = start. elapsed ( ) ;
9290 info ! (
9391 "Single item search: {:?} (found {} items)" ,
@@ -118,11 +116,11 @@ async fn test_bulk_operations() -> oo7::Result<()> {
118116 keyring
119117 . create_item (
120118 & format ! ( "Item {}" , i) ,
121- & HashMap :: from ( [
119+ & [
122120 ( "app" , "bulk_test" ) ,
123121 ( "index" , & i. to_string ( ) ) ,
124122 ( "batch" , "individual" ) ,
125- ] ) ,
123+ ] ,
126124 format ! ( "secret-{}" , i) ,
127125 false ,
128126 )
@@ -138,9 +136,7 @@ async fn test_bulk_operations() -> oo7::Result<()> {
138136
139137 // Test search performance with more items
140138 let start = Instant :: now ( ) ;
141- let items = keyring
142- . search_items ( & HashMap :: from ( [ ( "app" , "bulk_test" ) ] ) )
143- . await ?;
139+ let items = keyring. search_items ( & [ ( "app" , "bulk_test" ) ] ) . await ?;
144140 let search_time = start. elapsed ( ) ;
145141
146142 info ! (
@@ -179,7 +175,7 @@ async fn test_scaling_behavior() -> oo7::Result<()> {
179175 keyring
180176 . create_item (
181177 & format ! ( "Scale Item {}" , i) ,
182- & HashMap :: from ( [ ( "app" , "scaling_test" ) , ( "index" , & i. to_string ( ) ) ] ) ,
178+ & [ ( "app" , "scaling_test" ) , ( "index" , & i. to_string ( ) ) ] ,
183179 format ! ( "scaling-secret-{}" , i) ,
184180 false ,
185181 )
@@ -201,7 +197,7 @@ async fn test_scaling_behavior() -> oo7::Result<()> {
201197 keyring
202198 . create_item (
203199 "New Item" ,
204- & HashMap :: from ( [ ( "app" , "scaling_test" ) , ( "type" , "new" ) ] ) ,
200+ & [ ( "app" , "scaling_test" ) , ( "type" , "new" ) ] ,
205201 "new-secret" ,
206202 false ,
207203 )
@@ -211,9 +207,7 @@ async fn test_scaling_behavior() -> oo7::Result<()> {
211207
212208 // Test search performance
213209 let start = Instant :: now ( ) ;
214- let items = keyring
215- . search_items ( & HashMap :: from ( [ ( "app" , "scaling_test" ) ] ) )
216- . await ?;
210+ let items = keyring. search_items ( & [ ( "app" , "scaling_test" ) ] ) . await ?;
217211 let search_time = start. elapsed ( ) ;
218212 info ! (
219213 "Search keyring with {} items: {:?} (found {})" ,
@@ -246,11 +240,11 @@ async fn test_search_performance() -> oo7::Result<()> {
246240 keyring
247241 . create_item (
248242 & format ! ( "{} - {}" , app, user) ,
249- & HashMap :: from ( [
243+ & [
250244 ( "app" , * app) ,
251245 ( "user" , * user) ,
252246 ( "index" , & ( i * users. len ( ) + j) . to_string ( ) ) ,
253- ] ) ,
247+ ] ,
254248 format ! ( "{}-{}-secret" , app, user) ,
255249 false ,
256250 )
@@ -267,7 +261,7 @@ async fn test_search_performance() -> oo7::Result<()> {
267261 // 1. Exact match (should find 1 item)
268262 let start = Instant :: now ( ) ;
269263 let items = keyring
270- . search_items ( & HashMap :: from ( [ ( "app" , "browser" ) , ( "user" , "alice" ) ] ) )
264+ . search_items ( & [ ( "app" , "browser" ) , ( "user" , "alice" ) ] )
271265 . await ?;
272266 let exact_time = start. elapsed ( ) ;
273267 info ! (
@@ -278,9 +272,7 @@ async fn test_search_performance() -> oo7::Result<()> {
278272
279273 // 2. Single attribute match (should find multiple items)
280274 let start = Instant :: now ( ) ;
281- let items = keyring
282- . search_items ( & HashMap :: from ( [ ( "app" , "browser" ) ] ) )
283- . await ?;
275+ let items = keyring. search_items ( & [ ( "app" , "browser" ) ] ) . await ?;
284276 let single_attr_time = start. elapsed ( ) ;
285277 info ! (
286278 "Single attribute search: {:?} (found {} items)" ,
@@ -290,9 +282,7 @@ async fn test_search_performance() -> oo7::Result<()> {
290282
291283 // 3. No match
292284 let start = Instant :: now ( ) ;
293- let items = keyring
294- . search_items ( & HashMap :: from ( [ ( "app" , "nonexistent" ) ] ) )
295- . await ?;
285+ let items = keyring. search_items ( & [ ( "app" , "nonexistent" ) ] ) . await ?;
296286 let no_match_time = start. elapsed ( ) ;
297287 info ! (
298288 "No match search: {:?} (found {} items)" ,
0 commit comments