Debian Codegraph @

src/tests/mssql/simple.rs

raw
1 //! Other simple table/ column migrations
2 #![allow(unused_imports)]
3
4 use crate::backend::{MsSql, SqlGenerator};
5
6 #[test]
7 fn create_table() {
8 let sql = MsSql::create_table("table_to_create", None);
9 assert_eq!(String::from("CREATE TABLE [table_to_create]"), sql);
10 }
11
12 #[test]
13 fn create_table_with_schema() {
14 let sql = MsSql::create_table("table_to_create", Some("my_schema"));
15 assert_eq!(
16 String::from("CREATE TABLE [my_schema].[table_to_create]"),
17 sql
18 );
19 }
20
21 #[test]
22 fn create_table_if_not_exists() {
23 let sql = MsSql::create_table_if_not_exists("table_to_create", None);
24 assert_eq!(String::from("IF NOT EXISTS (SELECT * FROM sys.tables WHERE name=\'table_to_create\') CREATE TABLE [table_to_create]"), sql);
25 }
26
27 #[test]
28 fn drop_table() {
29 let sql = MsSql::drop_table("table_to_drop", None);
30 assert_eq!(String::from("DROP TABLE [table_to_drop]"), sql);
31 }
32
33 #[test]
34 fn drop_table_if_exists() {
35 let sql = MsSql::drop_table_if_exists("table_to_drop", None);
36 assert_eq!(String::from("DROP TABLE IF EXISTS [table_to_drop]"), sql);
37 }
38
39 #[test]
40 fn rename_table() {
41 let sql = MsSql::rename_table("old_table", "new_table", None);
42 assert_eq!(String::from("EXEC sp_rename 'old_table', 'new_table'"), sql);
43 }
44
45 #[test]
46 fn alter_table() {
47 let sql = MsSql::alter_table("table_to_alter", None);
48 assert_eq!(String::from("ALTER TABLE [table_to_alter]"), sql);
49 }
50
51 #[test]
52 fn drop_column() {
53 let sql = MsSql::drop_column("column_to_drop");
54 assert_eq!(String::from("DROP COLUMN [column_to_drop]"), sql);
55 }
56
57 #[test]
58 fn rename_column() {
59 let sql = MsSql::rename_column("table.old_column", "table.new_column");
60 assert_eq!(
61 String::from("EXEC sp_rename 'table.old_column', 'table.new_column'"),
62 sql
63 );
64 }