From 1775510b5b0226efafe9b7e52a42c17f185581de Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Wed, 15 Jan 2025 23:17:02 -0500 Subject: [PATCH] Async client: add a missing slash to API endpoint path --- Cargo.toml | 3 ++- src/api.rs | 2 +- tests/async_overview_tests.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/async_overview_tests.rs diff --git a/Cargo.toml b/Cargo.toml index c1ff542..f621931 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,11 +28,12 @@ reqwest = { version = "0.12.12", features = [ ], optional = true } backtrace = { version = "0.3", optional = true } thiserror = { version = "2", optional = true } +tokio = "1.43.0" [dev-dependencies] amqprs = { version = "2"} -cargo-nextest = "0.9.87" +cargo-nextest = "0.9.88" regex = { version = "1", features = ["std"] } [features] diff --git a/src/api.rs b/src/api.rs index 9028ba2..a871aae 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1622,7 +1622,7 @@ where where S: AsRef, { - format!("{}{}", self.endpoint, path.as_ref()) + format!("{}/{}", self.endpoint, path.as_ref()) } } diff --git a/tests/async_overview_tests.rs b/tests/async_overview_tests.rs new file mode 100644 index 0000000..377c9e5 --- /dev/null +++ b/tests/async_overview_tests.rs @@ -0,0 +1,29 @@ +// 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_overview() { + let endpoint = endpoint(); + let rc = Client::new(&endpoint, USERNAME, PASSWORD); + + let result1 = rc.overview().await; + assert!(result1.is_ok(), "overview returned {:?}", result1); + + let ov = result1.unwrap(); + assert!(ov.object_totals.exchanges > 0); +}