Add basic dbtests for space DDL
parent
5c62a842b4
commit
d090e5ce37
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Created on Wed Nov 29 2023
|
||||
*
|
||||
* This file is a part of Skytable
|
||||
* Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
|
||||
* NoSQL database written by Sayan Nandan ("the Author") with the
|
||||
* vision to provide flexibility in data modelling without compromising
|
||||
* on performance, queryability or scalability.
|
||||
*
|
||||
* Copyright (c) 2023, Sayan Nandan <ohsayan@outlook.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use skytable::error::Error;
|
||||
use {crate::engine::error::QueryError, sky_macros::dbtest, skytable::query};
|
||||
|
||||
const INVALID_SYNTAX_ERR: u16 = QueryError::QLInvalidSyntax.value_u8() as u16;
|
||||
|
||||
#[dbtest]
|
||||
fn ensure_create_space_end_of_tokens() {
|
||||
let mut con = db!();
|
||||
assert_err_eq!(
|
||||
con.query_parse::<()>(&query!("create space myspace with {} this_should_fail")),
|
||||
Error::ServerError(INVALID_SYNTAX_ERR)
|
||||
);
|
||||
assert_err_eq!(
|
||||
con.query_parse::<()>(&query!("create space myspace this_should_fail")),
|
||||
Error::ServerError(INVALID_SYNTAX_ERR)
|
||||
);
|
||||
}
|
||||
|
||||
#[dbtest]
|
||||
fn ensure_alter_space_end_of_tokens() {
|
||||
let mut con = db!();
|
||||
assert_err_eq!(
|
||||
con.query_parse::<()>(&query!("alter space myspace with {} this_should_fail")),
|
||||
Error::ServerError(INVALID_SYNTAX_ERR)
|
||||
);
|
||||
}
|
||||
|
||||
#[dbtest]
|
||||
fn ensure_drop_space_end_of_tokens() {
|
||||
let mut con = db!();
|
||||
assert_err_eq!(
|
||||
con.query_parse::<()>(&query!("drop space myspace this_should_fail")),
|
||||
Error::ServerError(INVALID_SYNTAX_ERR)
|
||||
);
|
||||
assert_err_eq!(
|
||||
con.query_parse::<()>(&query!("drop space myspace force this_should_fail")),
|
||||
Error::ServerError(INVALID_SYNTAX_ERR)
|
||||
);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Created on Wed Nov 29 2023
|
||||
*
|
||||
* This file is a part of Skytable
|
||||
* Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
|
||||
* NoSQL database written by Sayan Nandan ("the Author") with the
|
||||
* vision to provide flexibility in data modelling without compromising
|
||||
* on performance, queryability or scalability.
|
||||
*
|
||||
* Copyright (c) 2023, Sayan Nandan <ohsayan@outlook.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
macro_rules! assert_err_eq {
|
||||
($me:expr, $target:pat) => {
|
||||
match ::core::result::Result::unwrap_err($me) {
|
||||
$target => {}
|
||||
other => panic!(
|
||||
"expected error `{}` but got {:?} at {}:{}",
|
||||
stringify!($target),
|
||||
other,
|
||||
file!(),
|
||||
line!()
|
||||
),
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue