diff options
Diffstat (limited to 'index_test.go')
| -rw-r--r-- | index_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/index_test.go b/index_test.go index 5f6b375..f47dace 100644 --- a/index_test.go +++ b/index_test.go @@ -8,6 +8,7 @@ import ( ) func TestCreateRepoAndStage(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -24,6 +25,7 @@ func TestCreateRepoAndStage(t *testing.T) { } func TestIndexReadTree(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -53,6 +55,7 @@ func TestIndexReadTree(t *testing.T) { } func TestIndexWriteTreeTo(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -72,6 +75,7 @@ func TestIndexWriteTreeTo(t *testing.T) { } func TestIndexAddAndWriteTreeTo(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -105,7 +109,48 @@ 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) defer cleanupTestRepo(t, repo) @@ -127,6 +172,7 @@ func TestIndexAddAllNoCallback(t *testing.T) { } func TestIndexAddAllCallback(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -155,6 +201,7 @@ func TestIndexAddAllCallback(t *testing.T) { } func TestIndexOpen(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) |
