@@ -176,8 +176,9 @@ mod tests {
176
176
use super :: * ;
177
177
use crate :: email:: Emails ;
178
178
use crate :: models:: { Crate , NewCrate , NewUser , NewVersion , User , Version } ;
179
- use crate :: schema:: { crates, versions} ;
179
+ use crate :: schema:: { crate_downloads , crates, versions} ;
180
180
use crate :: test_util:: test_db_connection;
181
+ use chrono:: NaiveDateTime ;
181
182
use std:: collections:: BTreeMap ;
182
183
183
184
fn user ( conn : & mut PgConnection ) -> User {
@@ -235,9 +236,9 @@ mod tests {
235
236
. select ( versions:: downloads)
236
237
. first ( conn) ;
237
238
assert_eq ! ( version_downloads, Ok ( 1 ) ) ;
238
- let crate_downloads = crates :: table
239
+ let crate_downloads = crate_downloads :: table
239
240
. find ( krate. id )
240
- . select ( crates :: downloads)
241
+ . select ( crate_downloads :: downloads)
241
242
. first ( conn) ;
242
243
assert_eq ! ( crate_downloads, Ok ( 1 ) ) ;
243
244
super :: update ( conn) . unwrap ( ) ;
@@ -332,17 +333,19 @@ mod tests {
332
333
. unwrap ( ) ;
333
334
334
335
let version_before: Version = versions:: table. find ( version. id ) . first ( conn) . unwrap ( ) ;
335
- let krate_before: ( NaiveDateTime , i32 ) = crates:: table
336
- . select ( ( crates:: updated_at, crates:: downloads) )
336
+ let krate_before: ( NaiveDateTime , i64 ) = crates:: table
337
+ . inner_join ( crate_downloads:: table)
338
+ . select ( ( crates:: updated_at, crate_downloads:: downloads) )
337
339
. filter ( crates:: id. eq ( krate. id ) )
338
340
. first ( conn)
339
341
. unwrap ( ) ;
340
342
super :: update ( conn) . unwrap ( ) ;
341
343
let version2: Version = versions:: table. find ( version. id ) . first ( conn) . unwrap ( ) ;
342
344
assert_eq ! ( version2. downloads, 2 ) ;
343
345
assert_eq ! ( version2. updated_at, version_before. updated_at) ;
344
- let krate2: ( NaiveDateTime , i32 ) = crates:: table
345
- . select ( ( crates:: updated_at, crates:: downloads) )
346
+ let krate2: ( NaiveDateTime , i64 ) = crates:: table
347
+ . inner_join ( crate_downloads:: table)
348
+ . select ( ( crates:: updated_at, crate_downloads:: downloads) )
346
349
. filter ( crates:: id. eq ( krate. id ) )
347
350
. first ( conn)
348
351
. unwrap ( ) ;
0 commit comments