Skip to content

Commit

Permalink
parsing bye command as quit & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Phosphorus15 committed Mar 14, 2023
1 parent 469aa36 commit ea46f79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/controlchan/line_parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
let path = String::from_utf8_lossy(&path).to_string();
Command::Rmd { path }
}
"QUIT" => {
"QUIT" | "BYE" => {
let params = parse_to_eol(cmd_params)?;
if !params.is_empty() {
return Err(ParseErrorKind::InvalidCommand.into());
Expand Down
9 changes: 9 additions & 0 deletions src/server/controlchan/line_parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ fn parse_quit() {
assert_eq!(parse(input), Err(ParseError::from(ParseErrorKind::InvalidCommand)));
}

#[test]
fn parse_bye() {
let input = "BYE\r\n";
assert_eq!(parse(input), Ok(Command::Quit));

let input = "BYE BYE\r\n";
assert_eq!(parse(input), Err(ParseError::from(ParseErrorKind::InvalidCommand)));
}

#[test]
fn parse_mkd() {
let input = "MKD\r\n";
Expand Down

0 comments on commit ea46f79

Please sign in to comment.