tests(cmd): ensure wrong statements are recognized
This commit is contained in:
parent
92c50d6b65
commit
848775587e
5 changed files with 26 additions and 1 deletions
|
|
@ -67,10 +67,13 @@ CLOCK: [2025-05-03 sam. 21:15]--[2025-05-03 sam. 21:16] => 0:01
|
||||||
:LOGBOOK:
|
:LOGBOOK:
|
||||||
CLOCK: [2025-05-03 sam. 21:16]--[2025-05-03 sam. 21:18] => 0:02
|
CLOCK: [2025-05-03 sam. 21:16]--[2025-05-03 sam. 21:18] => 0:02
|
||||||
:END:
|
:END:
|
||||||
** TODO insta test wrong statement
|
** DONE insta test wrong statement
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:EFFORT: 10min
|
:EFFORT: 10min
|
||||||
:END:
|
:END:
|
||||||
|
:LOGBOOK:
|
||||||
|
CLOCK: [2025-05-03 sam. 21:18]--[2025-05-03 sam. 21:21] => 0:03
|
||||||
|
:END:
|
||||||
** TODO insta test wrong meta-command
|
** TODO insta test wrong meta-command
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:EFFORT: 10min
|
:EFFORT: 10min
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::meta_commands::{MetaCommand, MetaCommandExecuteResult, MetaCommandParseError};
|
use crate::meta_commands::{MetaCommand, MetaCommandExecuteResult, MetaCommandParseError};
|
||||||
use crate::statements::{Statement, StatementExecuteResult, StatementParseError};
|
use crate::statements::{Statement, StatementExecuteResult, StatementParseError};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
MetaCommand(MetaCommand),
|
MetaCommand(MetaCommand),
|
||||||
Statement(Statement),
|
Statement(Statement),
|
||||||
|
|
@ -45,6 +46,7 @@ impl Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum CommandParseError {
|
pub enum CommandParseError {
|
||||||
MetaCommand(MetaCommandParseError),
|
MetaCommand(MetaCommandParseError),
|
||||||
Statement(StatementParseError),
|
Statement(StatementParseError),
|
||||||
|
|
@ -126,4 +128,9 @@ mod tests {
|
||||||
fn test_execute_exit_metacommand() {
|
fn test_execute_exit_metacommand() {
|
||||||
assert_debug_snapshot!(Into::<Command>::into(MetaCommand::Exit).execute());
|
assert_debug_snapshot!(Into::<Command>::into(MetaCommand::Exit).execute());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_wrong_statement() {
|
||||||
|
assert_debug_snapshot!("salact".parse::<Command>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum MetaCommand {
|
pub enum MetaCommand {
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
@ -14,6 +15,7 @@ impl MetaCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum MetaCommandParseError {
|
pub enum MetaCommandParseError {
|
||||||
Unrecognized { cmd: String },
|
Unrecognized { cmd: String },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
source: src/command.rs
|
||||||
|
expression: "\"salact\".parse::<Command>()"
|
||||||
|
---
|
||||||
|
Err(
|
||||||
|
Statement(
|
||||||
|
Unrecognized {
|
||||||
|
stmt: "salact",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Statement {
|
pub enum Statement {
|
||||||
Insert,
|
Insert,
|
||||||
Select,
|
Select,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum StatementParseError {
|
pub enum StatementParseError {
|
||||||
Unrecognized { stmt: String },
|
Unrecognized { stmt: String },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue