Skip to content

Commit 25a7a13

Browse files
New test suite for more complex/longer scenarios
1 parent 6df13dc commit 25a7a13

File tree

7 files changed

+1476
-111
lines changed

7 files changed

+1476
-111
lines changed

src/commands.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,9 +1142,7 @@ pub fn list_plugins_across_cluster(client: APIClient) -> ClientResult<Vec<Plugin
11421142
//
11431143

11441144
pub fn declare_vhost(client: APIClient, command_args: &ArgMatches) -> ClientResult<()> {
1145-
// the flag is required
11461145
let name = command_args.get_one::<String>("name").unwrap();
1147-
// these are optional
11481146
let description = command_args
11491147
.get_one::<String>("description")
11501148
.map(|s| s.as_str());
@@ -1173,9 +1171,7 @@ pub fn declare_exchange(
11731171
vhost: &str,
11741172
command_args: &ArgMatches,
11751173
) -> Result<(), CommandRunError> {
1176-
// the flag is required
11771174
let name = command_args.get_one::<String>("name").unwrap();
1178-
// these are optional
11791175
let exchange_type = command_args
11801176
.get_one::<ExchangeType>("type")
11811177
.cloned()
@@ -1305,7 +1301,6 @@ pub fn delete_global_parameter(client: APIClient, command_args: &ArgMatches) ->
13051301
}
13061302

13071303
pub fn delete_vhost(client: APIClient, command_args: &ArgMatches) -> ClientResult<()> {
1308-
// the flag is required
13091304
let name = command_args.get_one::<String>("name").unwrap();
13101305
let idempotently = command_args
13111306
.get_one::<bool>("idempotently")
@@ -1413,7 +1408,6 @@ pub fn delete_multiple_vhosts(
14131408
}
14141409

14151410
pub fn delete_user(client: APIClient, command_args: &ArgMatches) -> ClientResult<()> {
1416-
// the flag is required
14171411
let name = command_args.get_one::<String>("name").unwrap();
14181412
let idempotently = command_args
14191413
.get_one::<bool>("idempotently")
@@ -1427,7 +1421,6 @@ pub fn delete_permissions(
14271421
vhost: &str,
14281422
command_args: &ArgMatches,
14291423
) -> ClientResult<()> {
1430-
// the flag is required
14311424
let user = command_args.get_one::<String>("user").unwrap();
14321425
let idempotently = command_args
14331426
.get_one::<bool>("idempotently")
@@ -1512,11 +1505,9 @@ pub fn declare_queue(
15121505
vhost: &str,
15131506
command_args: &ArgMatches,
15141507
) -> Result<(), CommandRunError> {
1515-
// the flag is required
15161508
let name = command_args.get_one::<String>("name").unwrap();
15171509
let queue_type = command_args.get_one::<QueueType>("type").cloned().unwrap();
15181510

1519-
// these are optional
15201511
let durable = command_args
15211512
.get_one::<bool>("durable")
15221513
.cloned()
@@ -1973,7 +1964,6 @@ pub fn declare_global_parameter(
19731964
}
19741965

19751966
pub fn delete_queue(client: APIClient, vhost: &str, command_args: &ArgMatches) -> ClientResult<()> {
1976-
// the flag is required
19771967
let name = command_args.get_one::<String>("name").unwrap();
19781968
let idempotently = command_args
19791969
.get_one::<bool>("idempotently")
@@ -2026,7 +2016,6 @@ pub fn delete_exchange(
20262016
vhost: &str,
20272017
command_args: &ArgMatches,
20282018
) -> ClientResult<()> {
2029-
// the flag is required
20302019
let name = command_args.get_one::<String>("name").unwrap();
20312020
let idempotent = command_args
20322021
.get_one::<bool>("idempotently")
@@ -2040,7 +2029,6 @@ pub fn delete_policy(
20402029
vhost: &str,
20412030
command_args: &ArgMatches,
20422031
) -> ClientResult<()> {
2043-
// the flag is required
20442032
let name = command_args.get_one::<String>("name").unwrap();
20452033
let idempotently = command_args
20462034
.get_one::<bool>("idempotently")
@@ -2054,7 +2042,6 @@ pub fn delete_operator_policy(
20542042
vhost: &str,
20552043
command_args: &ArgMatches,
20562044
) -> ClientResult<()> {
2057-
// the flag is required
20582045
let name = command_args.get_one::<String>("name").unwrap();
20592046
let idempotently = command_args
20602047
.get_one::<bool>("idempotently")
@@ -2064,7 +2051,6 @@ pub fn delete_operator_policy(
20642051
}
20652052

20662053
pub fn purge_queue(client: APIClient, vhost: &str, command_args: &ArgMatches) -> ClientResult<()> {
2067-
// the flag is required
20682054
let name = command_args.get_one::<String>("name").unwrap();
20692055
client.purge_queue(vhost, name)
20702056
}
@@ -2085,7 +2071,6 @@ pub fn health_check_port_listener(
20852071
client: APIClient,
20862072
command_args: &ArgMatches,
20872073
) -> ClientResult<()> {
2088-
// the flag is required
20892074
let port = command_args.get_one::<u16>("port").cloned().unwrap();
20902075
client.health_check_port_listener(port)
20912076
}
@@ -2094,7 +2079,6 @@ pub fn health_check_protocol_listener(
20942079
client: APIClient,
20952080
command_args: &ArgMatches,
20962081
) -> ClientResult<()> {
2097-
// the flag is required
20982082
let proto = command_args
20992083
.get_one::<SupportedProtocol>("protocol")
21002084
.cloned()
@@ -2103,7 +2087,6 @@ pub fn health_check_protocol_listener(
21032087
}
21042088

21052089
pub fn close_connection(client: APIClient, command_args: &ArgMatches) -> ClientResult<()> {
2106-
// the flag is required
21072090
let name = command_args.get_one::<String>("name").unwrap();
21082091
let idempotently = command_args
21092092
.get_one::<bool>("idempotently")
@@ -2113,7 +2096,6 @@ pub fn close_connection(client: APIClient, command_args: &ArgMatches) -> ClientR
21132096
}
21142097

21152098
pub fn close_user_connections(client: APIClient, command_args: &ArgMatches) -> ClientResult<()> {
2116-
// the flag is required
21172099
let username = command_args.get_one::<String>("username").unwrap();
21182100
let idempotently = command_args
21192101
.get_one::<bool>("idempotently")

tests/bindings_tests.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,18 @@ fn test_list_bindings() -> Result<(), Box<dyn Error>> {
2828
delete_vhost(vh1).expect("failed to delete a virtual host");
2929
delete_vhost(vh2).expect("failed to delete a virtual host");
3030

31-
// declare vhost 1
3231
run_succeeds(["declare", "vhost", "--name", vh1]);
3332

34-
// declare vhost 2
3533
run_succeeds(["declare", "vhost", "--name", vh2]);
3634

37-
// declare a new queue in vhost 1
3835
run_succeeds([
3936
"-V", vh1, "declare", "queue", "--name", q1, "--type", "classic",
4037
]);
4138

42-
// declare a new queue in vhost 2
4339
run_succeeds([
4440
"-V", vh2, "declare", "queue", "--name", q2, "--type", "quorum",
4541
]);
4642

47-
// bind the queue -> a pre-existing exchange
4843
run_succeeds([
4944
"-V",
5045
vh1,
@@ -60,7 +55,6 @@ fn test_list_bindings() -> Result<(), Box<dyn Error>> {
6055
"routing_key_queue",
6156
]);
6257

63-
// declare an exchange -> exchange binding
6458
run_succeeds([
6559
"-V",
6660
vh1,
@@ -78,17 +72,14 @@ fn test_list_bindings() -> Result<(), Box<dyn Error>> {
7872

7973
await_queue_metric_emission();
8074

81-
// list bindings in vhost 1
8275
run_succeeds(["-V", "bindings_vhost_1", "list", "bindings"]).stdout(
8376
output_includes("new_queue_1")
8477
.and(output_includes("routing_key_queue"))
8578
.and(output_includes("routing_key_exchange")),
8679
);
8780

88-
// delete the queue from vhost 1
8981
run_succeeds(["-V", vh1, "queues", "delete", "--name", q1]);
9082

91-
// these bindings were deleted with the queue
9283
run_succeeds(["-V", "bindings_vhost_1", "list", "bindings"]).stdout(
9384
output_includes("new_queue_1")
9485
.not()
@@ -113,23 +104,18 @@ fn test_bindings_list() -> Result<(), Box<dyn Error>> {
113104
delete_vhost(vh1).expect("failed to delete a virtual host");
114105
delete_vhost(vh2).expect("failed to delete a virtual host");
115106

116-
// declare vhost 1
117107
run_succeeds(["vhosts", "declare", "--name", vh1]);
118108

119-
// declare vhost 2
120109
run_succeeds(["vhosts", "declare", "--name", vh2]);
121110

122-
// declare a new queue in vhost 1
123111
run_succeeds([
124112
"-V", vh1, "queues", "declare", "--name", q1, "--type", "classic",
125113
]);
126114

127-
// declare a new queue in vhost 2
128115
run_succeeds([
129116
"-V", vh2, "queues", "declare", "--name", q2, "--type", "quorum",
130117
]);
131118

132-
// bind the queue -> a pre-existing exchange
133119
run_succeeds([
134120
"-V",
135121
vh1,
@@ -145,7 +131,6 @@ fn test_bindings_list() -> Result<(), Box<dyn Error>> {
145131
"routing_key_queue",
146132
]);
147133

148-
// declare an exchange -> exchange binding
149134
run_succeeds([
150135
"-V",
151136
vh1,
@@ -163,15 +148,12 @@ fn test_bindings_list() -> Result<(), Box<dyn Error>> {
163148

164149
await_queue_metric_emission();
165150

166-
// list bindings in vhost 1
167151
run_succeeds(["-V", vh1, "list", "bindings"]).stdout(
168152
output_includes("new_queue_1")
169153
.and(output_includes("routing_key_queue"))
170154
.and(output_includes("routing_key_exchange")),
171155
);
172156

173-
// delete a binding
174-
// declare an exchange -> exchange binding
175157
run_succeeds([
176158
"-V",
177159
vh1,
@@ -187,7 +169,6 @@ fn test_bindings_list() -> Result<(), Box<dyn Error>> {
187169
"routing_key_queue",
188170
]);
189171

190-
// ensure that the deleted binding is no longer listed
191172
run_succeeds(["-V", vh1, "list", "bindings"]).stdout(
192173
output_includes("new_queue_1")
193174
.not()

0 commit comments

Comments
 (0)