File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -732,5 +732,6 @@ pub fn set_config(cfg: &Config,
732
732
let contents = toml:: Value :: Table ( toml) . to_string ( ) ;
733
733
try!( file. seek ( SeekFrom :: Start ( 0 ) ) ) ;
734
734
try!( file. write_all ( contents. as_bytes ( ) ) ) ;
735
+ try!( file. file ( ) . set_len ( contents. len ( ) as u64 ) ) ;
735
736
Ok ( ( ) )
736
737
}
Original file line number Diff line number Diff line change @@ -580,6 +580,19 @@ fn login_with_no_cargo_dir() {
580
580
execs ( ) . with_status ( 0 ) ) ;
581
581
}
582
582
583
+ #[ test]
584
+ fn login_with_differently_sized_token ( ) {
585
+ // Verify that the configuration file gets properly trunchated.
586
+ let home = paths:: home ( ) . join ( "new-home" ) ;
587
+ t ! ( fs:: create_dir( & home) ) ;
588
+ assert_that ( cargo_process ( ) . arg ( "login" ) . arg ( "lmaolmaolmao" ) . arg ( "-v" ) ,
589
+ execs ( ) . with_status ( 0 ) ) ;
590
+ assert_that ( cargo_process ( ) . arg ( "login" ) . arg ( "lmao" ) . arg ( "-v" ) ,
591
+ execs ( ) . with_status ( 0 ) ) ;
592
+ assert_that ( cargo_process ( ) . arg ( "login" ) . arg ( "lmaolmaolmao" ) . arg ( "-v" ) ,
593
+ execs ( ) . with_status ( 0 ) ) ;
594
+ }
595
+
583
596
#[ test]
584
597
fn bad_license_file ( ) {
585
598
Package :: new ( "foo" , "1.0.0" ) . publish ( ) ;
You can’t perform that action at this time.
0 commit comments