File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,11 @@ impl<'a> VersionBuilder<'a> {
237
237
}
238
238
}
239
239
240
+ fn license ( mut self , license : Option < & ' a str > ) -> Self {
241
+ self . license = license;
242
+ self
243
+ }
244
+
240
245
fn build ( self , connection : & PgConnection , crate_id : i32 ) -> CargoResult < Version > {
241
246
let license = match self . license {
242
247
Some ( license) => Some ( license. to_owned ( ) ) ,
Original file line number Diff line number Diff line change @@ -29,8 +29,10 @@ fn index() {
29
29
let conn = app. diesel_database . get ( ) . unwrap ( ) ;
30
30
let u = :: new_user ( "foo" ) . create_or_update ( & conn) . unwrap ( ) ;
31
31
:: CrateBuilder :: new ( "foo_vers_index" , u. id )
32
- . version ( :: VersionBuilder :: new ( "2.0.0" ) )
33
- . version ( :: VersionBuilder :: new ( "2.0.1" ) )
32
+ . version ( :: VersionBuilder :: new ( "2.0.0" )
33
+ . license ( Some ( "MIT" ) ) )
34
+ . version ( :: VersionBuilder :: new ( "2.0.1" )
35
+ . license ( Some ( "MIT/Apache-2.0" ) ) )
34
36
. expect_build ( & conn) ;
35
37
let ids = versions:: table
36
38
. select ( versions:: id)
@@ -42,6 +44,14 @@ fn index() {
42
44
let mut response = ok_resp ! ( middle. call( & mut req) ) ;
43
45
let json: VersionList = :: json ( & mut response) ;
44
46
assert_eq ! ( json. versions. len( ) , 2 ) ;
47
+
48
+ for v in & json. versions {
49
+ match v. num . as_ref ( ) {
50
+ "2.0.0" => assert_eq ! ( v. license, Some ( String :: from( "MIT" ) ) ) ,
51
+ "2.0.1" => assert_eq ! ( v. license, Some ( String :: from( "MIT/Apache-2.0" ) ) ) ,
52
+ _ => panic ! ( "unexpected version" )
53
+ }
54
+ }
45
55
}
46
56
47
57
#[ test]
You can’t perform that action at this time.
0 commit comments