@@ -2537,6 +2537,78 @@ mod tests {
2537
2537
}
2538
2538
}
2539
2539
2540
+ #[ cfg_attr( feature = "runtime-tokio" , tokio:: test) ]
2541
+ #[ cfg_attr( feature = "runtime-async-std" , async_std:: test) ]
2542
+ async fn test_get_quota_root ( ) {
2543
+ {
2544
+ let response = b"* QUOTAROOT Sent Userquota\r \n \
2545
+ * QUOTA Userquota (STORAGE 4855 48576)\r \n \
2546
+ A0001 OK Getquotaroot completed (0.004 + 0.000 + 0.004 secs).\r \n "
2547
+ . to_vec ( ) ;
2548
+
2549
+ let mock_stream = MockStream :: new ( response) ;
2550
+ let mut session = mock_session ! ( mock_stream) ;
2551
+ let ( quotaroots, quota) = dbg ! ( session. get_quota_root( "Sent" ) . await . unwrap( ) ) ;
2552
+ assert_eq ! (
2553
+ str :: from_utf8( & session. stream. inner. written_buf) . unwrap( ) ,
2554
+ "A0001 GETQUOTAROOT \" Sent\" \r \n "
2555
+ ) ;
2556
+ assert_eq ! (
2557
+ quotaroots,
2558
+ vec![ QuotaRoot {
2559
+ mailbox_name: "Sent" . to_string( ) ,
2560
+ quota_root_names: vec![ "Userquota" . to_string( ) , ] ,
2561
+ } , ] ,
2562
+ ) ;
2563
+ assert_eq ! (
2564
+ quota,
2565
+ vec![ Quota {
2566
+ root_name: "Userquota" . to_string( ) ,
2567
+ resources: vec![ QuotaResource {
2568
+ name: QuotaResourceName :: Storage ,
2569
+ usage: 4855 ,
2570
+ limit: 48576 ,
2571
+ } ] ,
2572
+ } ]
2573
+ ) ;
2574
+ assert_eq ! ( quota[ 0 ] . resources[ 0 ] . get_usage_percentage( ) , 9 ) ;
2575
+ }
2576
+
2577
+ {
2578
+ let response = b"* QUOTAROOT \" INBOX\" \" #19\" \r \n \
2579
+ * QUOTA \" #19\" (STORAGE 0 0)\r \n \
2580
+ A0001 OK GETQUOTAROOT successful.\r \n "
2581
+ . to_vec ( ) ;
2582
+
2583
+ let mock_stream = MockStream :: new ( response) ;
2584
+ let mut session = mock_session ! ( mock_stream) ;
2585
+ let ( quotaroots, quota) = session. get_quota_root ( "INBOX" ) . await . unwrap ( ) ;
2586
+ assert_eq ! (
2587
+ str :: from_utf8( & session. stream. inner. written_buf) . unwrap( ) ,
2588
+ "A0001 GETQUOTAROOT \" INBOX\" \r \n "
2589
+ ) ;
2590
+ assert_eq ! (
2591
+ quotaroots,
2592
+ vec![ QuotaRoot {
2593
+ mailbox_name: "INBOX" . to_string( ) ,
2594
+ quota_root_names: vec![ "#19" . to_string( ) , ] ,
2595
+ } , ] ,
2596
+ ) ;
2597
+ assert_eq ! (
2598
+ quota,
2599
+ vec![ Quota {
2600
+ root_name: "#19" . to_string( ) ,
2601
+ resources: vec![ QuotaResource {
2602
+ name: QuotaResourceName :: Storage ,
2603
+ usage: 0 ,
2604
+ limit: 0 ,
2605
+ } ] ,
2606
+ } ]
2607
+ ) ;
2608
+ assert_eq ! ( quota[ 0 ] . resources[ 0 ] . get_usage_percentage( ) , 0 ) ;
2609
+ }
2610
+ }
2611
+
2540
2612
#[ cfg_attr( feature = "runtime-tokio" , tokio:: test) ]
2541
2613
#[ cfg_attr( feature = "runtime-async-std" , async_std:: test) ]
2542
2614
async fn test_parsing_error ( ) {
0 commit comments