Skip to content

Commit

Permalink
- impl SLOWLOG HELP (#96)
Browse files Browse the repository at this point in the history
- remove serial attrs for help tests
  • Loading branch information
ArtemIsmagilov authored Jan 6, 2025
1 parent ad2b990 commit 0edddc2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
33 changes: 33 additions & 0 deletions src/commands/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,39 @@ pub trait ServerCommands<'a> {
prepare_command(self, cmd("SLOWLOG").arg("GET").arg(options))
}

/// The command returns a helpful text describing the different SLOWLOG subcommands.
///
/// # Return
/// An array of strings.
///
/// # Example
/// ```
/// # use rustis::{
/// # client::Client,
/// # commands::ServerCommands,
/// # Result,
/// # };
/// #
/// # #[cfg_attr(feature = "tokio-runtime", tokio::main)]
/// # #[cfg_attr(feature = "async-std-runtime", async_std::main)]
/// # async fn main() -> Result<()> {
/// # let client = Client::connect("127.0.0.1:6379").await?;
/// let result: Vec<String> = client.slowlog_help().await?;
/// assert!(result.iter().any(|e| e == "HELP"));
/// # Ok(())
/// # }
/// ```
///
/// # See Also
/// [<https://redis.io/commands/slowlog-help/>](https://redis.io/commands/slowlog-help/)
#[must_use]
fn slowlog_help(self) -> PreparedCommand<'a, Self, Vec<String>>
where
Self: Sized,
{
prepare_command(self, cmd("SLOWLOG").arg("HELP"))
}

/// This command returns the current number of entries in the slow log.
///
/// # See Also
Expand Down
1 change: 0 additions & 1 deletion src/tests/connection_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ async fn client_getredir() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::main)]
#[cfg_attr(feature = "async-std-runtime", async_std::main)]
#[serial]
async fn client_help() -> Result<()> {
let client = get_test_client().await?;
let result: Vec<String> = client.client_help().await?;
Expand Down
1 change: 0 additions & 1 deletion src/tests/generic_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ async fn object_freq() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn object_help() -> Result<()> {
let client = get_test_client().await?;
let result: Vec<String> = client.object_help().await?;
Expand Down
17 changes: 11 additions & 6 deletions src/tests/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ async fn acl_getuser() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn acl_help() -> Result<()> {
let client = get_test_client().await?;

Expand Down Expand Up @@ -322,7 +321,6 @@ async fn command() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn command_help() -> Result<()> {
let client = get_test_client().await?;

Expand Down Expand Up @@ -481,7 +479,6 @@ async fn config_get() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::main)]
#[cfg_attr(feature = "async-std-runtime", async_std::main)]
#[serial]
async fn config_help() -> Result<()> {
let client = get_test_client().await?;
let result: Vec<String> = client.config_help().await?;
Expand Down Expand Up @@ -722,7 +719,6 @@ async fn latency_graph() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn latency_help() -> Result<()> {
let client = get_test_client().await?;

Expand Down Expand Up @@ -864,7 +860,6 @@ async fn memory_doctor() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn memory_help() -> Result<()> {
let client = get_test_client().await?;

Expand Down Expand Up @@ -941,7 +936,6 @@ async fn memory_usage() -> Result<()> {

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn module_help() -> Result<()> {
let client = get_test_client().await?;

Expand Down Expand Up @@ -1199,6 +1193,17 @@ async fn slowlog_get() -> Result<()> {
Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn slowlog_help() -> Result<()> {
let client = get_test_client().await?;

let result = client.slowlog_help().await?;
assert!(result.iter().any(|e| e == "HELP"));

Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
Expand Down

0 comments on commit 0edddc2

Please sign in to comment.