Skip to content

Commit 0d84b2a

Browse files
authored
fix integration test (#29)
* try fix integration test * try again * fix line ending differences
1 parent 81deeb3 commit 0d84b2a

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

tests/cli.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,23 @@ fn test_remote_file() -> Result<(), Box<dyn std::error::Error>> {
3232
assert!(path.is_file());
3333

3434
// Ensure cached version exactly matches local version.
35-
let cached_file = fs::File::open(&path)?;
36-
let cached_bytes: Result<Vec<u8>, _> = cached_file.bytes().collect();
37-
let cached_bytes = cached_bytes.unwrap();
38-
39-
let local_file = fs::File::open("test_fixtures/utf-8_sample/utf-8_sample.txt")?;
40-
let local_bytes: Result<Vec<u8>, _> = local_file.bytes().collect();
41-
let local_bytes = local_bytes.unwrap();
42-
43-
assert!(cached_bytes == local_bytes);
35+
let mut cached_file = fs::File::open(&path)?;
36+
let mut cached_contents = String::new();
37+
cached_file.read_to_string(&mut cached_contents)?;
38+
39+
let local_path: PathBuf = [".", "test_fixtures", "utf-8_sample", "utf-8_sample.txt"]
40+
.iter()
41+
.collect();
42+
assert!(local_path.is_file());
43+
let mut local_file = fs::File::open(local_path)?;
44+
let mut local_contents = String::new();
45+
local_file.read_to_string(&mut local_contents)?;
46+
47+
// On Windows, git will automatically convert '\n' line-endings to '\r\n'.
48+
// So we change those back.
49+
let local_contents = local_contents.replace("\r\n", "\n");
50+
51+
assert_eq!(local_contents, cached_contents);
4452

4553
Ok(())
4654
}

0 commit comments

Comments
 (0)