refactor: try to remove unnecessary tests in error mod (#750)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2023-03-06 12:31:30 +08:00
committed by GitHub
parent d4e0dc3685
commit b76b27f3bf
2 changed files with 0 additions and 192 deletions

View File

@@ -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());
}
}