Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#[test]
fn telemetry_cleanup_removes_old_files() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "telemetry", "on"]);
expect_ok(config, &["rustc", "--version"]);
let telemetry_dir = config.rustupdir.join("telemetry");
utils::ensure_dir_exists("telemetry",
&telemetry_dir,
multirust_utils::NotifyHandler::none());
let today = time::now_utc();
let mut d = today.sub(Duration::days(120));
let one_day = time::Duration::days(1);
for x in 0..110 {
let file_name = format!("log-{}-{:02}-{:02}.json", d.tm_year + 1900, d.tm_mon + 1, d.tm_mday);
let _ = raw::write_file(&telemetry_dir.join(&file_name), "");
d = d.add(one_day);
}
expect_ok(config, &["rustc", "--version"]);
let out = telemetry_dir.read_dir();
assert!(out.is_ok());
let contents = out.unwrap();
let count = contents.count();
assert!(count == 100);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment