diff options
Diffstat (limited to 'internal/git/gittest')
-rw-r--r-- | internal/git/gittest/repo.go | 22 | ||||
-rw-r--r-- | internal/git/gittest/repository_suite.go | 2 |
2 files changed, 7 insertions, 17 deletions
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go index e8b1c8113..0a3f0c036 100644 --- a/internal/git/gittest/repo.go +++ b/internal/git/gittest/repo.go @@ -38,24 +38,14 @@ func InitRepoDir(t testing.TB, storagePath, relativePath string) *gitalypb.Repos } } -// InitBareRepo creates a new bare repository -func InitBareRepo(t testing.TB) (*gitalypb.Repository, string, func()) { - return initRepoAt(t, true, config.Storage{Name: "default", Path: testhelper.GitlabTestStoragePath()}) -} - // InitBareRepoAt creates a new bare repository in the storage -func InitBareRepoAt(t testing.TB, storage config.Storage) (*gitalypb.Repository, string, func()) { - return initRepoAt(t, true, storage) -} - -// InitRepoWithWorktree creates a new repository with a worktree -func InitRepoWithWorktree(t testing.TB) (*gitalypb.Repository, string, func()) { - return initRepoAt(t, false, config.Storage{Name: "default", Path: testhelper.GitlabTestStoragePath()}) +func InitBareRepoAt(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, func()) { + return initRepoAt(t, cfg, true, storage) } // InitRepoWithWorktreeAtStorage creates a new repository with a worktree in the storage -func InitRepoWithWorktreeAtStorage(t testing.TB, storage config.Storage) (*gitalypb.Repository, string, func()) { - return initRepoAt(t, false, storage) +func InitRepoWithWorktreeAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, func()) { + return initRepoAt(t, cfg, false, storage) } // NewObjectPoolName returns a random pool repository name in format @@ -86,7 +76,7 @@ func newDiskHash(t testing.TB) string { return filepath.Join(b[0:2], b[2:4], b) } -func initRepoAt(t testing.TB, bare bool, storage config.Storage) (*gitalypb.Repository, string, func()) { +func initRepoAt(t testing.TB, cfg config.Cfg, bare bool, storage config.Storage) (*gitalypb.Repository, string, func()) { relativePath := NewRepositoryName(t, bare) repoPath := filepath.Join(storage.Path, relativePath) @@ -95,7 +85,7 @@ func initRepoAt(t testing.TB, bare bool, storage config.Storage) (*gitalypb.Repo args = append(args, "--bare") } - testhelper.MustRunCommand(t, nil, "git", append(args, repoPath)...) + Exec(t, cfg, append(args, repoPath)...) repo := InitRepoDir(t, storage.Path, relativePath) repo.StorageName = storage.Name diff --git a/internal/git/gittest/repository_suite.go b/internal/git/gittest/repository_suite.go index 8a14cac24..3c6bb0f8f 100644 --- a/internal/git/gittest/repository_suite.go +++ b/internal/git/gittest/repository_suite.go @@ -89,7 +89,7 @@ func testRepositoryHasBranches(t *testing.T, cfg config.Cfg, getRepository func( ctx, cancel := testhelper.Context() defer cancel() - pbRepo, repoPath, cleanup := InitBareRepoAt(t, cfg.Storages[0]) + pbRepo, repoPath, cleanup := InitBareRepoAt(t, cfg, cfg.Storages[0]) defer cleanup() repo := getRepository(t, pbRepo) |