@@ -32,15 +32,23 @@ fn test_remote_file() -> Result<(), Box<dyn std::error::Error>> {
32
32
assert ! ( path. is_file( ) ) ;
33
33
34
34
// 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) ;
44
52
45
53
Ok ( ( ) )
46
54
}
0 commit comments