Skip to content

Commit b179214

Browse files
committed
a better test!
1 parent d8a0355 commit b179214

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,33 @@ public void CanUpdateIndexWhenNothingHappened()
490490
}
491491
}
492492

493+
[Fact]
494+
public void IndexIsUpdatedAfterAddingFile()
495+
{
496+
const string fileName = "new-file.txt";
497+
498+
var path = SandboxAssumeUnchangedTestRepo();
499+
using (var repo = new Repository(path))
500+
{
501+
// create a file on disk
502+
Touch(repo.Info.WorkingDirectory, fileName, "hello test file\n");
503+
504+
repo.Index.Clear();
505+
repo.Index.Add(fileName);
506+
507+
var first = repo.Index[fileName].Id;
508+
509+
Touch(repo.Info.WorkingDirectory, fileName, "rewrite the file\n");
510+
511+
repo.Index.Update();
512+
513+
var second = repo.Index[fileName].Id;
514+
515+
Assert.NotEqual(first, second);
516+
}
517+
}
518+
519+
493520
private static void AddSomeCornerCases(Repository repo)
494521
{
495522
// Turn 1.txt into a directory in the Index

0 commit comments

Comments
 (0)