mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
test: add verification that localStorage.Root() resolves to the correct absolute filepath
This commit is contained in:
parent
e120fdb97e
commit
8821b67d1b
@ -17,7 +17,7 @@ func TestNewGoGitRepo(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(plainRoot)
|
defer os.RemoveAll(plainRoot)
|
||||||
|
|
||||||
_, err = InitGoGitRepo(plainRoot, testApplicationName)
|
_, err = InitGoGitRepo(plainRoot, namespace)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
plainGitDir := filepath.Join(plainRoot, ".git")
|
plainGitDir := filepath.Join(plainRoot, ".git")
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ func TestNewGoGitRepo(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.RemoveAll(bareRoot)
|
defer os.RemoveAll(bareRoot)
|
||||||
|
|
||||||
_, err = InitBareGoGitRepo(bareRoot, testApplicationName)
|
_, err = InitBareGoGitRepo(bareRoot, namespace)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
bareGitDir := bareRoot
|
bareGitDir := bareRoot
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ func TestNewGoGitRepo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
r, err := OpenGoGitRepo(tc.inPath, testApplicationName, nil)
|
r, err := OpenGoGitRepo(tc.inPath, namespace, nil)
|
||||||
|
|
||||||
if tc.err {
|
if tc.err {
|
||||||
require.Error(t, err, i)
|
require.Error(t, err, i)
|
||||||
@ -66,3 +66,36 @@ func TestNewGoGitRepo(t *testing.T) {
|
|||||||
func TestGoGitRepo(t *testing.T) {
|
func TestGoGitRepo(t *testing.T) {
|
||||||
RepoTest(t, CreateGoGitTestRepo, CleanupTestRepos)
|
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"))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user