Skip to content

Commit

Permalink
added test all charas
Browse files Browse the repository at this point in the history
  • Loading branch information
dylhack committed Aug 8, 2023
1 parent aba4d2c commit 658769b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/bot/commands/cowsay/fortune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ pub fn register(grp: &mut CreateApplicationCommandOption) {
pub async fn handle(ctx: &Context, cmd: &ApplicationCommandInteraction, subcmd: &CommandDataOption) -> CommandResult {
let fortune = get_fortune();
let mut chara = "cow";
println!("subcmd: {:?}", subcmd.options);
if let Some(chara_arg) = subcmd.options.get(0) {
println!("chara_arg: {:?}", chara_arg);
let chara_val = chara_arg.value.as_ref();
if let Some(chara_str) = chara_val {
chara = chara_str.as_str().unwrap_or("cow");
Expand Down
11 changes: 10 additions & 1 deletion src/cowsay/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn cowsay_to_image(data: &String) -> Result<Image> {
#[cfg(test)]
mod tests {
use super::*;
use crate::tmp::get_path;
use crate::{tmp::get_path, cowsay::{cowsay, BUILTIN_CHARA}};

#[test]
fn test_chop() {
Expand Down Expand Up @@ -288,4 +288,13 @@ mod tests {
let file_path = get_path(&format!("{}.webp", "test")).unwrap();
assert!(image.save(file_path).is_ok());
}

#[test]
pub fn test_all_charas() {
for chara in BUILTIN_CHARA {
let msg = cowsay(chara, "Hello world").unwrap();
let result = cowsay_to_image(&msg);
assert!(result.is_ok());
}
}
}

0 comments on commit 658769b

Please sign in to comment.