Add unit tests for existing commands

This commit is contained in:
Anthony Oteri
2023-09-26 16:09:52 -04:00
parent 292b44645a
commit a6cd95bfa4
4 changed files with 288 additions and 13 deletions
+15 -6
View File
@@ -17,6 +17,7 @@
#![deny(clippy::pedantic)]
use clap::Parser;
use std::io::{self, Write};
use url::Url;
use crate::cli::Cli;
@@ -63,18 +64,26 @@ async fn main() -> Result<(), DredgeError> {
let registry_url: Url = parse_registry_arg(&args.registry)?;
// -- Dispatch control to the appropriate command handler.
let mut buf: Vec<u8> = Vec::new();
match args.command {
Commands::Catalog => commands::catalog_handler(&registry_url).await?,
Commands::Tags { name } => commands::tags_handler(&registry_url, &name).await?,
Commands::Catalog => commands::catalog_handler(&mut buf, &registry_url).await?,
Commands::Tags { name } => commands::tags_handler(&mut buf, &registry_url, &name).await?,
Commands::Show { image, tag } => {
commands::show_handler(&registry_url, &image, &tag.unwrap_or(LATEST.to_string()))
.await?;
commands::show_handler(
&mut buf,
&registry_url,
&image,
&tag.unwrap_or(LATEST.to_string()),
)
.await?;
}
Commands::Delete { image, tag } => {
commands::delete_handler(&registry_url, &image, &tag).await?;
commands::delete_handler(&mut buf, &registry_url, &image, &tag).await?;
}
Commands::Check => commands::check_handler(&registry_url).await?,
Commands::Check => commands::check_handler(&mut buf, &registry_url).await?,
}
io::stdout().write_all(&buf)?;
Ok(())
}