|
227 | 227 | renamedFileURL = [NSURL fileURLWithPath:newPath isDirectory:NO];
|
228 | 228 | });
|
229 | 229 |
|
| 230 | + it(@"should add all files from the current file system to the index", ^{ |
| 231 | + NSData *currentFileContent = [[NSFileManager defaultManager] contentsAtPath:fileURL.path]; |
| 232 | + expect(currentFileContent).notTo(beNil()); |
| 233 | + NSString *currentFileString = [[NSString alloc] initWithData:currentFileContent encoding:NSUTF8StringEncoding]; |
| 234 | + currentFileString = [currentFileString stringByAppendingString:@"I would like to append this to the file"]; |
| 235 | + currentFileContent = [currentFileString dataUsingEncoding:NSUTF8StringEncoding]; |
| 236 | + expect(@([[NSFileManager defaultManager] createFileAtPath:fileURL.path contents:currentFileContent attributes:nil])).to(beTruthy()); |
| 237 | + |
| 238 | + NSString *newFileContent = @"This is a new file \n1 2 3"; |
| 239 | + NSData *newFileData = [newFileContent dataUsingEncoding:NSUTF8StringEncoding]; |
| 240 | + expect(newFileData).notTo(beNil()); |
| 241 | + expect(@([[NSFileManager defaultManager] createFileAtPath:renamedFileURL.path contents:newFileData attributes:nil])).to(beTruthy()); |
| 242 | + |
| 243 | + GTIndexEntry *entry = [index entryWithPath:[filename decomposedStringWithCanonicalMapping]]; |
| 244 | + expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeUnmodified, GTDeltaTypeModified))).to(beTruthy()); |
| 245 | + entry = [index entryWithPath:[renamedFilename decomposedStringWithCanonicalMapping]]; |
| 246 | + expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeUnmodified, GTDeltaTypeUntracked))).to(beTruthy()); |
| 247 | + |
| 248 | + expect(@([index addAll:NULL])).to(beTruthy()); |
| 249 | + expect(@([index write:NULL])).to(beTruthy()); |
| 250 | + |
| 251 | + entry = [index entryWithPath:[filename decomposedStringWithCanonicalMapping]]; |
| 252 | + expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeModified, GTDeltaTypeUnmodified))).to(beTruthy()); |
| 253 | + entry = [index entryWithPath:[renamedFilename decomposedStringWithCanonicalMapping]]; |
| 254 | + expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeAdded, GTDeltaTypeUnmodified))).to(beTruthy()); |
| 255 | + }); |
| 256 | + |
230 | 257 | it(@"it preserves decomposed Unicode in index paths with precomposeunicode disabled", ^{
|
231 | 258 | NSString *decomposedFilename = [filename decomposedStringWithCanonicalMapping];
|
232 | 259 | GTIndexEntry *entry = [index entryWithPath:decomposedFilename error:NULL];
|
|
0 commit comments