From 7860c63a8c6c36979877938ff84ec1e57ec8c646 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 16 Jan 2025 00:28:28 -0500 Subject: [PATCH] Port blocking_node_tests --- src/responses.rs | 2 +- tests/async_node_tests.rs | 41 ++++++++++++++++++++++++++++++++ tests/blocking_exchange_tests.rs | 1 - 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/async_node_tests.rs diff --git a/src/responses.rs b/src/responses.rs index 96457b3..6d4e0a0 100644 --- a/src/responses.rs +++ b/src/responses.rs @@ -1014,7 +1014,7 @@ pub struct QueueTotals { #[derive(Debug, Deserialize, Clone, PartialEq)] #[cfg_attr(feature = "tabled", derive(Tabled))] pub struct MessageStats { - /// Consumder delivery rate plus polling (via 'basic.get') rate + /// Consumer delivery rate plus polling (via 'basic.get') rate #[serde(rename = "deliver_get_details")] pub delivery_details: Rate, #[serde(rename = "publish_details")] diff --git a/tests/async_node_tests.rs b/tests/async_node_tests.rs new file mode 100644 index 0000000..18e38d1 --- /dev/null +++ b/tests/async_node_tests.rs @@ -0,0 +1,41 @@ +// Copyright (C) 2023-2025 RabbitMQ Core Team (teamrabbitmq@gmail.com) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +use rabbitmq_http_client::api::Client; + +mod test_helpers; +use crate::test_helpers::{endpoint, PASSWORD, USERNAME}; + +#[tokio::test] +async fn test_async_list_nodes() { + let endpoint = endpoint(); + let rc = Client::new(&endpoint, USERNAME, PASSWORD); + let result = rc.list_nodes().await; + + assert!(result.is_ok()); + let vec = result.unwrap(); + assert!(vec.iter().any(|n| n.name.starts_with("rabbit@"))) +} + +#[tokio::test] +async fn test_async_get_node_info() { + let endpoint = endpoint(); + let rc = Client::new(&endpoint, USERNAME, PASSWORD); + let nodes = rc.list_nodes().await.unwrap(); + let name = nodes.first().unwrap().name.clone(); + let node = &rc.get_node_info(&name).await.unwrap(); + + assert!(node.processors >= 1); + assert!(node.uptime >= 1); + assert!(node.total_erlang_processes >= 1); +} diff --git a/tests/blocking_exchange_tests.rs b/tests/blocking_exchange_tests.rs index a3646cf..3293b40 100644 --- a/tests/blocking_exchange_tests.rs +++ b/tests/blocking_exchange_tests.rs @@ -83,7 +83,6 @@ fn test_declare_a_durable_exchange_of_type(name: &str, typ: ExchangeType) { _ => ExchangeParams::durable_fanout(name, optional_args), }; let result2 = rc.declare_exchange(vhost, ¶ms); - println!("{:?}", result2); assert!(result2.is_ok()); let _ = rc.delete_exchange(vhost, name, false);