From 2387f7f955d4dc3e9f3d962a225f5f66dca6f6aa Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 23 Jun 2024 09:06:25 +0000 Subject: [PATCH] move tester command under debug Signed-off-by: Jason Volk --- src/admin/debug/mod.rs | 7 +++++++ src/admin/{tester/mod.rs => debug/tester.rs} | 8 ++++---- src/admin/handler.rs | 9 ++------- src/admin/mod.rs | 1 - 4 files changed, 13 insertions(+), 12 deletions(-) rename src/admin/{tester/mod.rs => debug/tester.rs} (76%) diff --git a/src/admin/debug/mod.rs b/src/admin/debug/mod.rs index 27e36a73..eed3b633 100644 --- a/src/admin/debug/mod.rs +++ b/src/admin/debug/mod.rs @@ -1,8 +1,10 @@ mod commands; +pub(crate) mod tester; use clap::Subcommand; use conduit::Result; use ruma::{events::room::message::RoomMessageEventContent, EventId, OwnedRoomOrAliasId, RoomId, ServerName}; +use tester::TesterCommand; use self::commands::*; @@ -157,6 +159,10 @@ pub(super) enum DebugCommand { /// - Print extended memory usage MemoryStats, + + /// - Developer test stubs + #[command(subcommand)] + Tester(TesterCommand), } pub(super) async fn process(command: DebugCommand, body: Vec<&str>) -> Result { @@ -207,5 +213,6 @@ pub(super) async fn process(command: DebugCommand, body: Vec<&str>) -> Result resolve_true_destination(body, server_name, no_cache).await?, DebugCommand::MemoryStats => memory_stats(), + DebugCommand::Tester(command) => tester::process(command, body).await?, }) } diff --git a/src/admin/tester/mod.rs b/src/admin/debug/tester.rs similarity index 76% rename from src/admin/tester/mod.rs rename to src/admin/debug/tester.rs index 69dc7540..6982ef52 100644 --- a/src/admin/tester/mod.rs +++ b/src/admin/debug/tester.rs @@ -4,15 +4,15 @@ use crate::Result; #[derive(clap::Subcommand)] #[cfg_attr(test, derive(Debug))] -pub(super) enum TesterCommands { +pub(crate) enum TesterCommand { Tester, Timer, } -pub(super) async fn process(command: TesterCommands, body: Vec<&str>) -> Result { +pub(super) async fn process(command: TesterCommand, body: Vec<&str>) -> Result { match command { - TesterCommands::Tester => tester(body).await, - TesterCommands::Timer => timer(body).await, + TesterCommand::Tester => tester(body).await, + TesterCommand::Timer => timer(body).await, } } diff --git a/src/admin/handler.rs b/src/admin/handler.rs index bda295c3..ca8545d9 100644 --- a/src/admin/handler.rs +++ b/src/admin/handler.rs @@ -13,11 +13,10 @@ use conduit::Result; pub(crate) use service::admin::{Command, Service}; use service::admin::{CommandOutput, CommandResult, HandlerResult}; -use self::{fsck::FsckCommand, tester::TesterCommands}; use crate::{ appservice, appservice::AppserviceCommand, debug, debug::DebugCommand, federation, federation::FederationCommand, - fsck, media, media::MediaCommand, query, query::QueryCommand, room, room::RoomCommand, server, - server::ServerCommand, services, tester, user, user::UserCommand, + fsck, fsck::FsckCommand, media, media::MediaCommand, query, query::QueryCommand, room, room::RoomCommand, server, + server::ServerCommand, services, user, user::UserCommand, }; pub(crate) const PAGE_SIZE: usize = 100; @@ -60,9 +59,6 @@ pub(crate) enum AdminCommand { #[command(subcommand)] /// - Query all the database getters and iterators Fsck(FsckCommand), - - #[command(subcommand)] - Tester(TesterCommands), } #[must_use] @@ -169,7 +165,6 @@ async fn process_admin_command(command: AdminCommand, body: Vec<&str>) -> Result AdminCommand::Debug(command) => debug::process(command, body).await?, AdminCommand::Query(command) => query::process(command, body).await?, AdminCommand::Fsck(command) => fsck::process(command, body).await?, - AdminCommand::Tester(command) => tester::process(command, body).await?, }; Ok(reply_message_content) diff --git a/src/admin/mod.rs b/src/admin/mod.rs index 33158b5c..29830a86 100644 --- a/src/admin/mod.rs +++ b/src/admin/mod.rs @@ -9,7 +9,6 @@ pub(crate) mod media; pub(crate) mod query; pub(crate) mod room; pub(crate) mod server; -pub(crate) mod tester; pub(crate) mod user; pub(crate) mod utils;