mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-19 22:40:40 +00:00
refactor: try to remove unnecessary tests in error mod (#750)
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -185,63 +185,3 @@ impl ErrorExt for Error {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::assert_matches::assert_matches;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn throw_sp_error() -> std::result::Result<(), ParserError> {
|
||||
Err(ParserError::ParserError("parser error".to_string()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_syntax_error() {
|
||||
let err = throw_sp_error()
|
||||
.context(SyntaxSnafu { sql: "" })
|
||||
.err()
|
||||
.unwrap();
|
||||
assert_matches!(
|
||||
err,
|
||||
Error::Syntax {
|
||||
sql: _,
|
||||
source: ParserError::ParserError { .. }
|
||||
}
|
||||
);
|
||||
assert_eq!(StatusCode::InvalidSyntax, err.status_code());
|
||||
|
||||
let err = throw_sp_error()
|
||||
.context(UnexpectedSnafu {
|
||||
sql: "",
|
||||
expected: "",
|
||||
actual: "",
|
||||
})
|
||||
.err()
|
||||
.unwrap();
|
||||
assert_eq!(StatusCode::InvalidSyntax, err.status_code());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unsupported_error() {
|
||||
let err = Error::Unsupported {
|
||||
sql: "".to_string(),
|
||||
keyword: "".to_string(),
|
||||
};
|
||||
assert_eq!(StatusCode::Unsupported, err.status_code());
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_tokenizer_error() {
|
||||
let err = Error::Tokenizer {
|
||||
sql: "".to_string(),
|
||||
source: sqlparser::tokenizer::TokenizerError {
|
||||
message: "tokenizer error".to_string(),
|
||||
col: 1,
|
||||
line: 1,
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(StatusCode::InvalidSyntax, err.status_code());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user