Skip to content

Commit

Permalink
[#110] handle_drop_database_query 테스트케이스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Aug 13, 2024
1 parent 6a4c23f commit 87d050b
Showing 1 changed file with 53 additions and 9 deletions.
62 changes: 53 additions & 9 deletions src/parser/test/drop_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,59 @@ fn test_handle_drop_database_query() {
want_error: bool,
}

let test_cases = vec![TestCase {
name: "DROP DATABASE test_db;".into(),
input: vec![Token::Identifier("test_db".to_owned()), Token::SemiColon],
expected: DropDatabaseQuery::builder()
.set_name("test_db".to_owned())
.build()
.into(),
want_error: false,
}];
let test_cases = vec![
TestCase {
name: "DROP DATABASE test_db;".into(),
input: vec![Token::Identifier("test_db".to_owned()), Token::SemiColon],
expected: DropDatabaseQuery::builder()
.set_name("test_db".to_owned())
.build()
.into(),
want_error: false,
},
TestCase {
name: "DROP DATABASE test_db".into(),
input: vec![Token::Identifier("test_db".to_owned())],
expected: DropDatabaseQuery::builder()
.set_name("test_db".to_owned())
.build()
.into(),
want_error: false,
},
TestCase {
name: "DROP DATABASE IF EXISTS test_db;".into(),
input: vec![
Token::If,
Token::Exists,
Token::Identifier("test_db".to_owned()),
Token::SemiColon,
],
expected: DropDatabaseQuery::builder()
.set_name("test_db".to_owned())
.set_if_exists(true)
.build()
.into(),
want_error: false,
},
TestCase {
name: "오류: DROP DATABASE IF EXISTS".into(),
input: vec![Token::If, Token::Exists],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: DROP DATABASE IF EXISTS DELETE".into(),
input: vec![Token::If, Token::Exists, Token::Delete],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: DROP DATABASE test_db&&".into(),
input: vec![Token::Identifier("test_db".to_owned()), Token::And],
expected: Default::default(),
want_error: true,
},
];

for t in test_cases {
let mut parser = Parser::new(t.input);
Expand Down

0 comments on commit 87d050b

Please sign in to comment.