(&self, expected: &[u8])
| 141 | } |
| 142 | |
| 143 | fn roundtrip(&self, expected: &[u8]) { |
| 144 | let repo = Repository::open(self.root.path()).unwrap(); |
| 145 | let current = repo.current_view().to_string(); |
| 146 | drop(repo); |
| 147 | self.atomic(&["view", "switch", "before-rename"]); |
| 148 | assert_eq!(fs::read(self.root.path().join("old.txt")).unwrap(), BASE); |
| 149 | assert!(!self.root.path().join("new.txt").exists()); |
| 150 | self.atomic(&["view", "switch", ¤t]); |
| 151 | // Reconstruct from recorded data, rather than accepting retained bytes. |
| 152 | fs::remove_file(self.root.path().join("new.txt")).unwrap(); |
| 153 | let repo = Repository::open(self.root.path()).unwrap(); |
| 154 | repo.materialize(repo.require_working_copy_id().unwrap()) |
| 155 | .unwrap(); |
| 156 | assert_eq!( |
| 157 | fs::read(self.root.path().join("new.txt")).unwrap(), |
| 158 | expected |
| 159 | ); |
| 160 | assert!(!self.root.path().join("old.txt").exists()); |
| 161 | self.assert_identity(&repo); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | #[test] |
no test coverage detected