Skip to content

Commit

Permalink
[#110] handle_alter_database_query 테스트케이스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Aug 13, 2024
1 parent 71e61dd commit 3a400b2
Showing 1 changed file with 72 additions and 1 deletion.
73 changes: 72 additions & 1 deletion src/parser/test/alter_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::ast::ddl::alter_database::{
};
use crate::ast::SQLStatement;
use crate::lexer::tokens::Token;
use crate::parser::context::ParserContext;
use crate::parser::predule::Parser;

#[test]
Expand Down Expand Up @@ -35,6 +34,23 @@ fn test_handle_alter_database_query() {
.into(),
want_error: false,
},
TestCase {
name: "ALTER DATABASE foo RENAME TO bar".into(),
input: vec![
Token::Identifier("foo".to_owned()),
Token::Rename,
Token::To,
Token::Identifier("bar".to_owned()),
],
expected: AlterDatabaseQuery::builder()
.set_name("foo".to_owned())
.set_action(AlterDatabaseAction::RenameTo(AlterDatabaseRenameTo {
name: "bar".into(),
}))
.build()
.into(),
want_error: false,
},
TestCase {
name: "ALTER DATABASE foo".into(),
input: vec![Token::Identifier("foo".to_owned())],
Expand All @@ -44,6 +60,61 @@ fn test_handle_alter_database_query() {
.into(),
want_error: false,
},
TestCase {
name: "오류: 빈 토큰".into(),
input: vec![],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: ALTER DATABASE DELETE".into(),
input: vec![Token::Delete],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: ALTER DATABASE foo RENAME".into(),
input: vec![Token::Identifier("foo".to_owned()), Token::Rename],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: ALTER DATABASE foo RENAME CREATE".into(),
input: vec![
Token::Identifier("foo".to_owned()),
Token::Rename,
Token::Create,
],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: ALTER DATABASE foo RENAME TO".into(),
input: vec![
Token::Identifier("foo".to_owned()),
Token::Rename,
Token::To,
],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: ALTER DATABASE foo RENAME TO ALTER".into(),
input: vec![
Token::Identifier("foo".to_owned()),
Token::Rename,
Token::To,
Token::Alter,
],
expected: Default::default(),
want_error: true,
},
TestCase {
name: "오류: ALTER DATABASE foo DELETE".into(),
input: vec![Token::Identifier("foo".to_owned()), Token::Delete],
expected: Default::default(),
want_error: true,
},
];

for t in test_cases {
Expand Down

0 comments on commit 3a400b2

Please sign in to comment.