summaryrefslogtreecommitdiff
path: root/index_test.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2016-10-31 20:03:05 +0100
committerGitHub <[email protected]>2016-10-31 20:03:05 +0100
commit42a90d4e68177eb2caad5eb4eed94bf01db308c2 (patch)
treeced946be713d218639d70399dd24116571ec243d /index_test.go
parente9668545c972870637b79670bcb532401353c3d6 (diff)
parentc18c8693feb805d9ffbd1d22444683ce5ac96477 (diff)
Merge pull request #351 from ezwiebel/index-remove-directory
Implement git_index_remove_directory in index wrapper
Diffstat (limited to 'index_test.go')
-rw-r--r--index_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/index_test.go b/index_test.go
index 600b8b1..f47dace 100644
--- a/index_test.go
+++ b/index_test.go
@@ -109,6 +109,46 @@ func TestIndexAddAndWriteTreeTo(t *testing.T) {
}
}
+func TestIndexRemoveDirectory(t *testing.T) {
+ repo := createTestRepo(t)
+ defer cleanupTestRepo(t, repo)
+
+ odb, err := repo.Odb()
+ checkFatal(t, err)
+
+ blobID, err := odb.Write([]byte("fou\n"), ObjectBlob)
+ checkFatal(t, err)
+
+ idx, err := NewIndex()
+ checkFatal(t, err)
+
+ entryCount := idx.EntryCount()
+ if entryCount != 0 {
+ t.Fatal("Index should count 0 entry")
+ }
+
+ entry := IndexEntry{
+ Path: "path/to/LISEZ_MOI",
+ Id: blobID,
+ Mode: FilemodeBlob,
+ }
+
+ err = idx.Add(&entry)
+ checkFatal(t, err)
+
+ entryCount = idx.EntryCount()
+ if entryCount != 1 {
+ t.Fatal("Index should count 1 entry")
+ }
+
+ err = idx.RemoveDirectory("path", 0)
+
+ entryCount = idx.EntryCount()
+ if entryCount != 0 {
+ t.Fatal("Index should count 0 entry")
+ }
+}
+
func TestIndexAddAllNoCallback(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)