@@ -119,6 +119,24 @@ mod tests {
119
119
);"# ,
120
120
] ;
121
121
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
+
122
140
fn setup_simple_schema ( conn : & InferConnection ) {
123
141
use diesel:: prelude:: * ;
124
142
use diesel:: sql_query;
@@ -135,6 +153,12 @@ mod tests {
135
153
sql_query ( * m) . execute ( conn) . unwrap ( ) ;
136
154
}
137
155
}
156
+ #[ cfg( feature = "mysql" ) ]
157
+ InferConnection :: Mysql ( conn) => {
158
+ for m in MIGRATION {
159
+ sql_query ( * m) . execute ( conn) . unwrap ( ) ;
160
+ }
161
+ }
138
162
}
139
163
}
140
164
@@ -147,7 +171,7 @@ mod tests {
147
171
148
172
#[ cfg( feature = "postgres" ) ]
149
173
print ( & conn, Some ( "infer_test" ) , & mut out) . unwrap ( ) ;
150
- #[ cfg( feature = "sqlite" ) ]
174
+ #[ cfg( any ( feature = "mysql" , feature = " sqlite") ) ]
151
175
print ( & conn, None , & mut out) . unwrap ( ) ;
152
176
153
177
let s = String :: from_utf8 ( out) . unwrap ( ) ;
@@ -179,7 +203,7 @@ mod tests {
179
203
let mut api_file = File :: create ( api) . unwrap ( ) ;
180
204
#[ cfg( feature = "postgres" ) ]
181
205
print ( & conn, Some ( "infer_test" ) , & mut api_file) . unwrap ( ) ;
182
- #[ cfg( feature = "sqlite" ) ]
206
+ #[ cfg( any ( feature = "mysql" , feature = " sqlite") ) ]
183
207
print ( & conn, None , & mut api_file) . unwrap ( ) ;
184
208
185
209
let main = tmp_dir
@@ -216,6 +240,17 @@ mod tests {
216
240
)
217
241
. unwrap ( ) ;
218
242
243
+ #[ cfg( feature = "mysql" ) ]
244
+ write ! (
245
+ main_file,
246
+ include_str!( "template_main.rs" ) ,
247
+ conn = "MysqlConnection" ,
248
+ db_url = std:: env:: var( "DATABASE_URL" ) . unwrap( ) ,
249
+ migrations = migrations,
250
+ listen_url = listen_url
251
+ )
252
+ . unwrap ( ) ;
253
+
219
254
let cargo_toml = tmp_dir. path ( ) . join ( "wundergraph_roundtrip_test/Cargo.toml" ) ;
220
255
let mut cargo_toml_file = std:: fs:: OpenOptions :: new ( )
221
256
. write ( true )
@@ -261,6 +296,21 @@ mod tests {
261
296
)
262
297
. unwrap ( ) ;
263
298
}
299
+ #[ cfg( feature = "mysql" ) ]
300
+ {
301
+ writeln ! (
302
+ cargo_toml_file,
303
+ r#"diesel = {{version = "1.4", features = ["mysql", "chrono"]}}"#
304
+ )
305
+ . unwrap ( ) ;
306
+
307
+ writeln ! (
308
+ cargo_toml_file,
309
+ "wundergraph = {{path = \" {}\" , features = [\" mysql\" , \" chrono\" ] }}" ,
310
+ wundergraph_dir
311
+ )
312
+ . unwrap ( ) ;
313
+ }
264
314
writeln ! ( cargo_toml_file, r#"juniper = "0.14""# ) . unwrap ( ) ;
265
315
writeln ! ( cargo_toml_file, r#"failure = "0.1""# ) . unwrap ( ) ;
266
316
writeln ! ( cargo_toml_file, r#"actix-web = "1""# ) . unwrap ( ) ;
0 commit comments