reshape/tests/remove_table.rs
fabianlindfors 9cac25299a Refactor tests to use test framework
This has the added benefit of removing the need for builders and the
derive_builder dependency.
2022-01-15 16:15:31 +01:00

43 lines
914 B
Rust

mod common;
use common::Test;
#[test]
fn remove_table() {
let mut test = Test::new("Remove table");
test.first_migration(
r#"
name = "create_users_table"
[[actions]]
type = "create_table"
name = "users"
primary_key = ["id"]
[[actions.columns]]
name = "id"
type = "INTEGER"
"#,
);
test.second_migration(
r#"
name = "remove_users_table"
[[actions]]
type = "remove_table"
table = "users"
"#,
);
test.intermediate(|old_db, new_db| {
// Make sure inserts work against the old schema
old_db
.simple_query("INSERT INTO users(id) VALUES (1)")
.unwrap();
// Ensure the table is not accessible through the new schema
assert!(new_db.query("SELECT id FROM users", &[]).is_err());
});
}