diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-01-10 11:52:51 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-01-12 12:56:15 +0300 |
commit | 077fe1a8996e3ee6ef0e288491962154cb89e0af (patch) | |
tree | de0416cae1fbf35a617980210f0b3effbaf4b7b3 /internal/middleware | |
parent | 863ea5eccf9b0f4e2de290b7cf04ec5e8f8ddf45 (diff) |
testcfg: Convert callers of `BuildWithRepo()`
The `BuildWithRepo()` function builds a Gitaly configuration and at the
same time creates a seed repository. There's two issues with this:
- It is a layering violation as the configuration-related code
should not depend on the repository-related logic. This means that
e.g. the `gittest` package cannot depend on the `testcfg` package
even though it is at a conceptually higher level.
- It hides away the parameters used to create the repository. This
means that we use seed repositories by default, but also that we
skip creation via the Repository service. Both are bad and should
require the caller to explicitly state that they want this.
Convert callers of `BuildWithRepo()` to instead use `Build()` to build
the configuration and `gittest.CreateRepository()` to create the
repository. Remove the now-unused `BuildWithRepo()` function.
Diffstat (limited to 'internal/middleware')
-rw-r--r-- | internal/middleware/commandstatshandler/commandstatshandler_test.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/middleware/commandstatshandler/commandstatshandler_test.go b/internal/middleware/commandstatshandler/commandstatshandler_test.go index e3583531a..e1ce12996 100644 --- a/internal/middleware/commandstatshandler/commandstatshandler_test.go +++ b/internal/middleware/commandstatshandler/commandstatshandler_test.go @@ -74,7 +74,13 @@ func getBufDialer(listener *bufconn.Listener) func(context.Context, string) (net } func TestInterceptor(t *testing.T) { - cfg, repo, _ := testcfg.BuildWithRepo(t) + ctx := testhelper.Context(t) + cfg := testcfg.Build(t) + + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + Seed: gittest.SeedGitLabTest, + }) logger, hook := test.NewNullLogger() @@ -88,8 +94,6 @@ func TestInterceptor(t *testing.T) { require.NoError(t, err) }() - ctx := testhelper.Context(t) - tests := []struct { name string performRPC func(ctx context.Context, client gitalypb.RefServiceClient) |