Skip to content

Commit

Permalink
Auto merge of #3002 - untitaker:trunchate-cargo-config, r=alexcrichton
Browse files Browse the repository at this point in the history
Trunchate cargo config properly

None
  • Loading branch information
bors committed Aug 16, 2016
2 parents cd8ad10 + da3db83 commit 5593045
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,5 +732,6 @@ pub fn set_config(cfg: &Config,
let contents = toml::Value::Table(toml).to_string();
try!(file.seek(SeekFrom::Start(0)));
try!(file.write_all(contents.as_bytes()));
try!(file.file().set_len(contents.len() as u64));
Ok(())
}
13 changes: 13 additions & 0 deletions tests/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,19 @@ fn login_with_no_cargo_dir() {
execs().with_status(0));
}

#[test]
fn login_with_differently_sized_token() {
// Verify that the configuration file gets properly trunchated.
let home = paths::home().join("new-home");
t!(fs::create_dir(&home));
assert_that(cargo_process().arg("login").arg("lmaolmaolmao").arg("-v"),
execs().with_status(0));
assert_that(cargo_process().arg("login").arg("lmao").arg("-v"),
execs().with_status(0));
assert_that(cargo_process().arg("login").arg("lmaolmaolmao").arg("-v"),
execs().with_status(0));
}

#[test]
fn bad_license_file() {
Package::new("foo", "1.0.0").publish();
Expand Down

0 comments on commit 5593045

Please sign in to comment.