diff options
-rw-r--r-- | repository/gogit_test.go | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/repository/gogit_test.go b/repository/gogit_test.go index 941b563a..d7b919b9 100644 --- a/repository/gogit_test.go +++ b/repository/gogit_test.go @@ -17,7 +17,7 @@ func TestNewGoGitRepo(t *testing.T) { require.NoError(t, err) defer os.RemoveAll(plainRoot) - _, err = InitGoGitRepo(plainRoot, testApplicationName) + _, err = InitGoGitRepo(plainRoot, namespace) require.NoError(t, err) plainGitDir := filepath.Join(plainRoot, ".git") @@ -26,7 +26,7 @@ func TestNewGoGitRepo(t *testing.T) { require.NoError(t, err) defer os.RemoveAll(bareRoot) - _, err = InitBareGoGitRepo(bareRoot, testApplicationName) + _, err = InitBareGoGitRepo(bareRoot, namespace) require.NoError(t, err) bareGitDir := bareRoot @@ -52,7 +52,7 @@ func TestNewGoGitRepo(t *testing.T) { } for i, tc := range tests { - r, err := OpenGoGitRepo(tc.inPath, testApplicationName, nil) + r, err := OpenGoGitRepo(tc.inPath, namespace, nil) if tc.err { require.Error(t, err, i) @@ -66,3 +66,36 @@ func TestNewGoGitRepo(t *testing.T) { func TestGoGitRepo(t *testing.T) { RepoTest(t, CreateGoGitTestRepo, CleanupTestRepos) } + +func TestGoGitRepo_Indexes(t *testing.T) { + t.Parallel() + + plainRoot, err := ioutil.TempDir("", "") + require.NoError(t, err) + // defer os.RemoveAll(plainRoot) + + repo, err := InitGoGitRepo(plainRoot, namespace) + require.NoError(t, err) + + // Can create indices + indexA, err := repo.GetBleveIndex("a") + require.NoError(t, err) + require.NotZero(t, indexA) + require.FileExists(t, filepath.Join(plainRoot, ".git", namespace, "indexes", "a", "index_meta.json")) + require.FileExists(t, filepath.Join(plainRoot, ".git", namespace, "indexes", "a", "store")) + + indexB, err := repo.GetBleveIndex("b") + require.NoError(t, err) + require.NotZero(t, indexB) + require.DirExists(t, filepath.Join(plainRoot, ".git", namespace, "indexes", "b")) + + // Can get an existing index + indexA, err = repo.GetBleveIndex("a") + require.NoError(t, err) + require.NotZero(t, indexA) + + // Can delete an index + err = repo.ClearBleveIndex("a") + require.NoError(t, err) + require.NoDirExists(t, filepath.Join(plainRoot, ".git", namespace, "indexes", "a")) +} |