mssql_testing/
fixtures.rs1pub struct TestFixture {
5 pub database: String,
7 pub tables: Vec<String>,
9}
10
11impl TestFixture {
12 #[must_use]
14 pub fn new(database: impl Into<String>) -> Self {
15 Self {
16 database: database.into(),
17 tables: Vec::new(),
18 }
19 }
20
21 #[must_use]
23 pub fn with_table(mut self, table: impl Into<String>) -> Self {
24 self.tables.push(table.into());
25 self
26 }
27
28 #[must_use]
30 pub fn create_database_sql(&self) -> String {
31 format!(
32 "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '{db}')
33 CREATE DATABASE [{db}]",
34 db = self.database
35 )
36 }
37
38 #[must_use]
40 pub fn drop_database_sql(&self) -> String {
41 format!(
42 "IF EXISTS (SELECT * FROM sys.databases WHERE name = '{db}')
43 DROP DATABASE [{db}]",
44 db = self.database
45 )
46 }
47}