diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-01-24 15:50:02 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-02-02 14:20:39 +0300 |
commit | 74e6566350c46d830160591e8560c93e06a64007 (patch) | |
tree | fa160922410864cc166082ebf313fc8bfe0f08a3 | |
parent | 7779f09eb8bf76508b1393c697deb15711ed0721 (diff) |
Return a copy of the repository from CreateRepository
Some tests modify the repository that is returned from CreateRepository.
To allow for the clean up function to still succeed, this commit returns
a copy of the repository instead so the clean up still targets the correct
repository.
-rw-r--r-- | internal/git/gittest/repo.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go index 8ddd8e217..8734fff18 100644 --- a/internal/git/gittest/repo.go +++ b/internal/git/gittest/repo.go @@ -21,6 +21,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" ) const ( @@ -154,7 +155,11 @@ func CreateRepository(ctx context.Context, t testing.TB, cfg config.Cfg, configs require.NoError(t, err) }) - return repository, filepath.Join(storage.Path, testhelper.GetReplicaPath(ctx, t, conn, repository)) + // Return a cloned repository so the above clean up function still targets the correct repository + // if the tests modify the returned repository. + clonedRepo := proto.Clone(repository).(*gitalypb.Repository) + + return clonedRepo, filepath.Join(storage.Path, testhelper.GetReplicaPath(ctx, t, conn, repository)) } // InitRepoOpts contains options for InitRepo. |