Skip to content

Commit

Permalink
[#110] handle_drop_table_query 테스트코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Aug 13, 2024
1 parent 039fc10 commit c7e613b
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/parser/test/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,56 @@ fn test_handle_alter_table_query() {
}
}
}

#[test]
fn test_handle_drop_table_query() {
struct TestCase {
name: String,
input: Vec<Token>,
expected: SQLStatement,
want_error: bool,
}

let test_cases = vec![
TestCase {
name: "DROP TABLE foo".into(),
input: vec![Token::Identifier("foo".to_owned())],
expected: DropTableQuery::builder()
.set_table(TableName::new(None, "foo".to_owned()))
.build()
.into(),
want_error: false,
},
TestCase {
name: "오류: DROP TABLE foo DROP".into(),
input: vec![Token::Identifier("foo".to_owned()), Token::Drop],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: 빈 토큰".into(),
input: vec![],
expected: Default::default(),
want_error: true,
},
];

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

let got = parser.handle_drop_table_query(Default::default());

assert_eq!(
got.is_err(),
t.want_error,
"{}: want_error: {}, error: {:?}",
t.name,
t.want_error,
got.err()
);

if let Ok(statements) = got {
assert_eq!(statements, t.expected.into(), "TC: {}", t.name);
}
}
}

0 comments on commit c7e613b

Please sign in to comment.