|
12 | 12 | // See the License for the specific language governing permissions and
|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 |
| -use assert_cmd::Command; |
16 | 15 | use predicates::prelude::*;
|
17 | 16 |
|
18 | 17 | mod test_helpers;
|
19 | 18 | use crate::test_helpers::*;
|
20 | 19 |
|
21 | 20 | #[test]
|
22 | 21 | fn list_queues() -> Result<(), Box<dyn std::error::Error>> {
|
| 22 | + let vh1 = "queue_vhost_1"; |
| 23 | + let vh2 = "queue_vhost_2"; |
| 24 | + let q1 = "new_queue1"; |
| 25 | + let q2 = "new_queue2"; |
| 26 | + |
| 27 | + delete_vhost(vh1).expect("failed to delete a virtual host"); |
| 28 | + delete_vhost(vh2).expect("failed to delete a virtual host"); |
| 29 | + |
23 | 30 | // declare vhost 1
|
24 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
25 |
| - cmd.args(["declare", "vhost", "--name", "queue_vhost_1"]); |
26 |
| - cmd.assert().success(); |
| 31 | + run_succeeds(["declare", "vhost", "--name", vh1]); |
27 | 32 |
|
28 | 33 | // declare vhost 2
|
29 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
30 |
| - cmd.args(["declare", "vhost", "--name", "queue_vhost_2"]); |
31 |
| - cmd.assert().success(); |
| 34 | + run_succeeds(["declare", "vhost", "--name", vh2]); |
32 | 35 |
|
33 |
| - // declare new queue in vhost 1 |
34 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
35 |
| - cmd.arg("-V") |
36 |
| - .arg("queue_vhost_1") |
37 |
| - .arg("declare") |
38 |
| - .arg("queue") |
39 |
| - .arg("--name") |
40 |
| - .arg("new_queue1") |
41 |
| - .arg("--type") |
42 |
| - .arg("classic"); |
43 |
| - cmd.assert().success(); |
| 36 | + // declare a new queue in vhost 1 |
| 37 | + run_succeeds(["-V", vh1, "declare", "queue", "--name", q1, "--type", "classic"]); |
44 | 38 |
|
45 | 39 | // declare new queue in vhost 2
|
46 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
47 |
| - cmd.arg("-V") |
48 |
| - .arg("queue_vhost_2") |
49 |
| - .arg("declare") |
50 |
| - .arg("queue") |
51 |
| - .arg("--name") |
52 |
| - .arg("new_queue2") |
53 |
| - .arg("--type") |
54 |
| - .arg("quorum"); |
55 |
| - cmd.assert().success(); |
| 40 | + run_succeeds(["-V", vh2, "declare", "queue", "--name", q2, "--type", "quorum"]); |
56 | 41 |
|
57 | 42 | await_queue_metric_emission();
|
58 | 43 |
|
59 | 44 | // list queues in vhost 1
|
60 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
61 |
| - cmd.args(["-V", "queue_vhost_1", "list", "queues"]); |
62 |
| - cmd.assert().success().stdout( |
63 |
| - predicate::str::contains("new_queue1").and(predicate::str::contains("new_queue2").not()), |
| 45 | + run_succeeds(["-V", vh1, "list", "queues"]).stdout( |
| 46 | + predicate::str::contains(q1).and(predicate::str::contains("new_queue2").not()), |
64 | 47 | );
|
65 | 48 |
|
66 |
| - // delete the queues from vhost 1 |
67 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
68 |
| - cmd.arg("-V") |
69 |
| - .arg("queue_vhost_1") |
70 |
| - .arg("delete") |
71 |
| - .arg("queue") |
72 |
| - .arg("--name") |
73 |
| - .arg("new_queue1"); |
74 |
| - cmd.assert().success(); |
75 |
| - |
76 |
| - // list queue in vhost 1 |
77 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
78 |
| - cmd.arg("-V").arg("queue_vhost_1").arg("list").arg("queues"); |
79 |
| - cmd.assert() |
80 |
| - .success() |
81 |
| - .stdout(predicate::str::contains("new_queue1").not()); |
| 49 | + // delete the queue in vhost 1 |
| 50 | + run_succeeds(["-V", vh1, "delete", "queue", "--name", q1]); |
82 | 51 |
|
83 |
| - // delete vhost 1 |
84 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
85 |
| - cmd.args(["delete", "vhost", "--name", "queue_vhost_1"]); |
86 |
| - cmd.assert().success(); |
| 52 | + // list queues in vhost 1 |
| 53 | + run_succeeds(["-V", vh1, "list", "queues"]).stdout( |
| 54 | + predicate::str::contains(q1).not() |
| 55 | + ); |
87 | 56 |
|
88 |
| - // delete vhost 2 |
89 |
| - let mut cmd = Command::cargo_bin("rabbitmqadmin")?; |
90 |
| - cmd.args(["delete", "vhost", "--name", "queue_vhost_2"]); |
91 |
| - cmd.assert().success(); |
| 57 | + delete_vhost(vh1).expect("failed to delete a virtual host"); |
| 58 | + delete_vhost(vh2).expect("failed to delete a virtual host"); |
92 | 59 |
|
93 | 60 | Ok(())
|
94 | 61 | }
|
0 commit comments