1
- use std:: process:: Command ;
2
1
// Copyright (C) 2023-2024 RabbitMQ Core Team ([email protected] )
3
2
//
4
3
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,38 +11,27 @@ use std::process::Command;
12
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
12
// See the License for the specific language governing permissions and
14
13
// limitations under the License.
15
- use assert_cmd:: prelude:: * ;
16
14
use predicates:: prelude:: * ;
17
15
16
+ mod test_helpers;
17
+ use crate :: test_helpers:: * ;
18
+
18
19
#[ test]
19
20
fn test_vhost_limits ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
20
- let mut cmd = Command :: cargo_bin ( "rabbitmqadmin" ) ?;
21
-
22
- cmd. args ( [
21
+ let limit_name = "max-connections" ;
22
+ run_succeeds ( [
23
23
"declare" ,
24
24
"vhost_limit" ,
25
25
"--name" ,
26
- "max-connections" ,
26
+ limit_name ,
27
27
"--value" ,
28
28
"1234" ,
29
29
] ) ;
30
- cmd. assert ( ) . success ( ) ;
31
-
32
- let mut cmd = Command :: cargo_bin ( "rabbitmqadmin" ) ?;
33
- cmd. args ( [ "list" , "vhost_limits" ] ) ;
34
- cmd. assert ( )
35
- . success ( )
36
- . stdout ( predicate:: str:: contains ( "max-connections" ) . and ( predicate:: str:: contains ( "1234" ) ) ) ;
37
-
38
- let mut cmd = Command :: cargo_bin ( "rabbitmqadmin" ) ?;
39
- cmd. args ( [ "delete" , "vhost_limit" , "--name" , "max-connections" ] ) ;
40
- cmd. assert ( ) . success ( ) ;
41
30
42
- let mut cmd = Command :: cargo_bin ( "rabbitmqadmin" ) ?;
43
- cmd. args ( [ "list" , "vhost_limits" ] ) ;
44
- cmd. assert ( )
45
- . success ( )
46
- . stdout ( predicate:: str:: contains ( "max-connections" ) . not ( ) ) ;
31
+ run_succeeds ( [ "list" , "vhost_limits" ] )
32
+ . stdout ( predicate:: str:: contains ( limit_name) . and ( predicate:: str:: contains ( "1234" ) ) ) ;
33
+ run_succeeds ( [ "delete" , "vhost_limit" , "--name" , limit_name] ) ;
34
+ run_succeeds ( [ "list" , "vhost_limits" ] ) . stdout ( predicate:: str:: contains ( limit_name) . not ( ) ) ;
47
35
48
36
Ok ( ( ) )
49
37
}
0 commit comments