@@ -125,6 +125,24 @@ mod tests {
125
125
);"# ,
126
126
] ;
127
127
128
+ #[ cfg( feature = "mysql" ) ]
129
+ const MIGRATION : & [ & str ] = & [
130
+ "CREATE TABLE users(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, name TEXT NOT NULL);" ,
131
+ r#"CREATE TABLE posts(
132
+ id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
133
+ author INTEGER REFERENCES users(id),
134
+ title TEXT NOT NULL,
135
+ datetime TIMESTAMP,
136
+ content TEXT
137
+ );"# ,
138
+ r#"CREATE TABLE comments(
139
+ id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
140
+ post INTEGER REFERENCES posts(id),
141
+ commenter INTEGER REFERENCES users(id),
142
+ content TEXT NOT NULL
143
+ );"# ,
144
+ ] ;
145
+
128
146
fn setup_simple_schema ( conn : & InferConnection ) {
129
147
use diesel:: prelude:: * ;
130
148
use diesel:: sql_query;
@@ -141,6 +159,12 @@ mod tests {
141
159
sql_query ( * m) . execute ( conn) . unwrap ( ) ;
142
160
}
143
161
}
162
+ #[ cfg( feature = "mysql" ) ]
163
+ InferConnection :: Mysql ( conn) => {
164
+ for m in MIGRATION {
165
+ sql_query ( * m) . execute ( conn) . unwrap ( ) ;
166
+ }
167
+ }
144
168
}
145
169
}
146
170
@@ -153,7 +177,7 @@ mod tests {
153
177
154
178
#[ cfg( feature = "postgres" ) ]
155
179
print ( & conn, Some ( "infer_test" ) , & mut out) . unwrap ( ) ;
156
- #[ cfg( feature = "sqlite" ) ]
180
+ #[ cfg( any ( feature = "mysql" , feature = " sqlite") ) ]
157
181
print ( & conn, None , & mut out) . unwrap ( ) ;
158
182
159
183
let s = String :: from_utf8 ( out) . unwrap ( ) ;
@@ -187,7 +211,7 @@ mod tests {
187
211
let mut api_file = File :: create ( api) . unwrap ( ) ;
188
212
#[ cfg( feature = "postgres" ) ]
189
213
print ( & conn, Some ( "infer_test" ) , & mut api_file) . unwrap ( ) ;
190
- #[ cfg( feature = "sqlite" ) ]
214
+ #[ cfg( any ( feature = "mysql" , feature = " sqlite") ) ]
191
215
print ( & conn, None , & mut api_file) . unwrap ( ) ;
192
216
193
217
let main = tmp_dir
@@ -224,6 +248,17 @@ mod tests {
224
248
)
225
249
. unwrap ( ) ;
226
250
251
+ #[ cfg( feature = "mysql" ) ]
252
+ write ! (
253
+ main_file,
254
+ include_str!( "template_main.rs" ) ,
255
+ conn = "MysqlConnection" ,
256
+ db_url = std:: env:: var( "DATABASE_URL" ) . unwrap( ) ,
257
+ migrations = migrations,
258
+ listen_url = listen_url
259
+ )
260
+ . unwrap ( ) ;
261
+
227
262
let cargo_toml = tmp_dir. path ( ) . join ( "wundergraph_roundtrip_test/Cargo.toml" ) ;
228
263
let mut cargo_toml_file = std:: fs:: OpenOptions :: new ( )
229
264
. write ( true )
@@ -269,6 +304,21 @@ mod tests {
269
304
)
270
305
. unwrap ( ) ;
271
306
}
307
+ #[ cfg( feature = "mysql" ) ]
308
+ {
309
+ writeln ! (
310
+ cargo_toml_file,
311
+ r#"diesel = {{version = "1.4", features = ["mysql", "chrono"]}}"#
312
+ )
313
+ . unwrap ( ) ;
314
+
315
+ writeln ! (
316
+ cargo_toml_file,
317
+ "wundergraph = {{path = \" {}\" , features = [\" mysql\" , \" chrono\" ] }}" ,
318
+ wundergraph_dir
319
+ )
320
+ . unwrap ( ) ;
321
+ }
272
322
writeln ! ( cargo_toml_file, r#"juniper = "0.14""# ) . unwrap ( ) ;
273
323
writeln ! ( cargo_toml_file, r#"failure = "0.1""# ) . unwrap ( ) ;
274
324
writeln ! ( cargo_toml_file, r#"actix-web = "1""# ) . unwrap ( ) ;
0 commit comments