diff --git a/notes.org b/notes.org index c42db6f..10ec924 100644 --- a/notes.org +++ b/notes.org @@ -67,10 +67,13 @@ CLOCK: [2025-05-03 sam. 21:15]--[2025-05-03 sam. 21:16] => 0:01 :LOGBOOK: CLOCK: [2025-05-03 sam. 21:16]--[2025-05-03 sam. 21:18] => 0:02 :END: -** TODO insta test wrong statement +** DONE insta test wrong statement :PROPERTIES: :EFFORT: 10min :END: +:LOGBOOK: +CLOCK: [2025-05-03 sam. 21:18]--[2025-05-03 sam. 21:21] => 0:03 +:END: ** TODO insta test wrong meta-command :PROPERTIES: :EFFORT: 10min diff --git a/src/command.rs b/src/command.rs index 4962ac3..40ca37e 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,6 +1,7 @@ use crate::meta_commands::{MetaCommand, MetaCommandExecuteResult, MetaCommandParseError}; use crate::statements::{Statement, StatementExecuteResult, StatementParseError}; +#[derive(Debug)] pub enum Command { MetaCommand(MetaCommand), Statement(Statement), @@ -45,6 +46,7 @@ impl Command { } } +#[derive(Debug)] pub enum CommandParseError { MetaCommand(MetaCommandParseError), Statement(StatementParseError), @@ -126,4 +128,9 @@ mod tests { fn test_execute_exit_metacommand() { assert_debug_snapshot!(Into::::into(MetaCommand::Exit).execute()); } + + #[test] + fn test_parse_wrong_statement() { + assert_debug_snapshot!("salact".parse::()); + } } diff --git a/src/meta_commands.rs b/src/meta_commands.rs index 8f5368f..e81beb9 100644 --- a/src/meta_commands.rs +++ b/src/meta_commands.rs @@ -1,3 +1,4 @@ +#[derive(Debug)] pub enum MetaCommand { Exit, } @@ -14,6 +15,7 @@ impl MetaCommand { } } +#[derive(Debug)] pub enum MetaCommandParseError { Unrecognized { cmd: String }, } diff --git a/src/snapshots/osdb__command__tests__parse_wrong_statement.snap b/src/snapshots/osdb__command__tests__parse_wrong_statement.snap new file mode 100644 index 0000000..90bd81a --- /dev/null +++ b/src/snapshots/osdb__command__tests__parse_wrong_statement.snap @@ -0,0 +1,11 @@ +--- +source: src/command.rs +expression: "\"salact\".parse::()" +--- +Err( + Statement( + Unrecognized { + stmt: "salact", + }, + ), +) diff --git a/src/statements.rs b/src/statements.rs index b755f75..0e58d5f 100644 --- a/src/statements.rs +++ b/src/statements.rs @@ -1,8 +1,10 @@ +#[derive(Debug)] pub enum Statement { Insert, Select, } +#[derive(Debug)] pub enum StatementParseError { Unrecognized { stmt: String }, }