diff options
| author | onur-ozkan <work@onurozkan.dev> | 2023-10-14 22:52:49 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2023-10-14 22:52:49 +0300 |
| commit | d16e89dc9d8ebfcf4a475585223fd23a5b36cee0 (patch) | |
| tree | 7365460c91beb8d1ae1e592d79ddf5f59329cef2 /src/bootstrap | |
| parent | 3be453d0bb854e190e1da914d7660b1e24501494 (diff) | |
| download | rust-d16e89dc9d8ebfcf4a475585223fd23a5b36cee0.tar.gz rust-d16e89dc9d8ebfcf4a475585223fd23a5b36cee0.zip | |
add unit test for Config::verify
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/config/tests.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/bootstrap/config/tests.rs b/src/bootstrap/config/tests.rs index d091f33eee4..ae8363b6de9 100644 --- a/src/bootstrap/config/tests.rs +++ b/src/bootstrap/config/tests.rs @@ -3,7 +3,12 @@ use crate::config::TomlConfig; use super::{Config, Flags}; use clap::CommandFactory; use serde::Deserialize; -use std::{env, path::Path}; +use std::{ + env, + fs::{remove_file, File}, + io::Write, + path::Path, +}; fn parse(config: &str) -> Config { Config::parse_inner(&["check".to_owned(), "--config=/does/not/exist".to_owned()], |&_| { @@ -196,3 +201,19 @@ fn rust_optimize() { fn invalid_rust_optimize() { parse("rust.optimize = \"a\""); } + +#[test] +fn verify_file_integrity() { + let config = parse(""); + + let tempfile = config.tempdir().join(".tmp-test-file"); + File::create(&tempfile).unwrap().write_all(b"dummy value").unwrap(); + assert!(tempfile.exists()); + + assert!( + config + .verify(&tempfile, "7e255dd9542648a8779268a0f268b891a198e9828e860ed23f826440e786eae5") + ); + + remove_file(tempfile).unwrap(); +} |
