File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ fn validate_license_expr(s: &str) -> AppResult<()> {
200
200
201
201
#[ cfg( test) ]
202
202
mod tests {
203
- use super :: TopVersions ;
203
+ use super :: { validate_license_expr , TopVersions } ;
204
204
use chrono:: NaiveDateTime ;
205
205
206
206
#[ track_caller]
@@ -270,4 +270,20 @@ mod tests {
270
270
}
271
271
) ;
272
272
}
273
+
274
+ #[ test]
275
+ fn licenses ( ) {
276
+ assert_ok ! ( validate_license_expr( "MIT" ) ) ;
277
+ assert_ok ! ( validate_license_expr( "MIT OR Apache-2.0" ) ) ;
278
+ assert_ok ! ( validate_license_expr( "MIT/Apache-2.0" ) ) ;
279
+ assert_ok ! ( validate_license_expr( "MIT AND Apache-2.0" ) ) ;
280
+
281
+ let error = assert_err ! ( validate_license_expr( "apache 2.0" ) ) ;
282
+ let error = format ! ( "{}" , error) ;
283
+ assert ! ( error. starts_with( "unknown license or other term: apache; see http" ) ) ;
284
+
285
+ let error = assert_err ! ( validate_license_expr( "MIT OR (Apache-2.0 AND MIT)" ) ) ;
286
+ let error = format ! ( "{}" , error) ;
287
+ assert ! ( error. starts_with( "unknown license or other term: (Apache-2.0; see http" ) ) ;
288
+ }
273
289
}
You can’t perform that action at this time.
0 commit comments