@@ -119,6 +119,24 @@ mod tests {
119119 );"# ,
120120 ] ;
121121
122+ #[ cfg( feature = "mysql" ) ]
123+ const MIGRATION : & [ & str ] = & [
124+ "CREATE TABLE users(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, name TEXT NOT NULL);" ,
125+ r#"CREATE TABLE posts(
126+ id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
127+ author INTEGER REFERENCES users(id),
128+ title TEXT NOT NULL,
129+ datetime TIMESTAMP,
130+ content TEXT
131+ );"# ,
132+ r#"CREATE TABLE comments(
133+ id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
134+ post INTEGER REFERENCES posts(id),
135+ commenter INTEGER REFERENCES users(id),
136+ content TEXT NOT NULL
137+ );"# ,
138+ ] ;
139+
122140 fn setup_simple_schema ( conn : & InferConnection ) {
123141 use diesel:: prelude:: * ;
124142 use diesel:: sql_query;
@@ -135,6 +153,12 @@ mod tests {
135153 sql_query ( * m) . execute ( conn) . unwrap ( ) ;
136154 }
137155 }
156+ #[ cfg( feature = "mysql" ) ]
157+ InferConnection :: Mysql ( conn) => {
158+ for m in MIGRATION {
159+ sql_query ( * m) . execute ( conn) . unwrap ( ) ;
160+ }
161+ }
138162 }
139163 }
140164
@@ -147,7 +171,7 @@ mod tests {
147171
148172 #[ cfg( feature = "postgres" ) ]
149173 print ( & conn, Some ( "infer_test" ) , & mut out) . unwrap ( ) ;
150- #[ cfg( feature = "sqlite" ) ]
174+ #[ cfg( any ( feature = "mysql" , feature = " sqlite") ) ]
151175 print ( & conn, None , & mut out) . unwrap ( ) ;
152176
153177 let s = String :: from_utf8 ( out) . unwrap ( ) ;
@@ -179,7 +203,7 @@ mod tests {
179203 let mut api_file = File :: create ( api) . unwrap ( ) ;
180204 #[ cfg( feature = "postgres" ) ]
181205 print ( & conn, Some ( "infer_test" ) , & mut api_file) . unwrap ( ) ;
182- #[ cfg( feature = "sqlite" ) ]
206+ #[ cfg( any ( feature = "mysql" , feature = " sqlite") ) ]
183207 print ( & conn, None , & mut api_file) . unwrap ( ) ;
184208
185209 let main = tmp_dir
@@ -216,6 +240,20 @@ mod tests {
216240 )
217241 . unwrap ( ) ;
218242
243+ #[ cfg( feature = "mysql" ) ]
244+ dbg ! ( std:: env:: var( "DATABASE_URL" ) . unwrap( ) ) ;
245+
246+ #[ cfg( feature = "mysql" ) ]
247+ write ! (
248+ main_file,
249+ include_str!( "template_main.rs" ) ,
250+ conn = "MysqlConnection" ,
251+ db_url = std:: env:: var( "DATABASE_URL" ) . unwrap( ) ,
252+ migrations = migrations,
253+ listen_url = listen_url
254+ )
255+ . unwrap ( ) ;
256+
219257 let cargo_toml = tmp_dir. path ( ) . join ( "wundergraph_roundtrip_test/Cargo.toml" ) ;
220258 let mut cargo_toml_file = std:: fs:: OpenOptions :: new ( )
221259 . write ( true )
@@ -261,6 +299,21 @@ mod tests {
261299 )
262300 . unwrap ( ) ;
263301 }
302+ #[ cfg( feature = "mysql" ) ]
303+ {
304+ writeln ! (
305+ cargo_toml_file,
306+ r#"diesel = {{version = "1.4", features = ["mysql", "chrono"]}}"#
307+ )
308+ . unwrap ( ) ;
309+
310+ writeln ! (
311+ cargo_toml_file,
312+ "wundergraph = {{path = \" {}\" , features = [\" mysql\" , \" chrono\" ] }}" ,
313+ wundergraph_dir
314+ )
315+ . unwrap ( ) ;
316+ }
264317 writeln ! ( cargo_toml_file, r#"juniper = "0.14""# ) . unwrap ( ) ;
265318 writeln ! ( cargo_toml_file, r#"failure = "0.1""# ) . unwrap ( ) ;
266319 writeln ! ( cargo_toml_file, r#"actix-web = "1""# ) . unwrap ( ) ;
0 commit comments