diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-03-07 19:35:12 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-04-04 13:54:32 +0300 |
commit | 5e161b1e9e6cef0e3f98e6a05d82fd7541634b7d (patch) | |
tree | 5a9cdd0b5d9304977a5beaecd20714d7bbf89f90 /internal/gitaly | |
parent | fe453bcfb58e8c4ab8e642ed068ced5880b11a96 (diff) |
Verify object pool existence after deletion in tests
TestDelete does not verify whether the object pool exists or not
after the call to DeleteObjectPool. This is somewhat of an imporant
assertion to make to ensure the deletion logic is working correctly.
This commit adds that missing assertion.
Diffstat (limited to 'internal/gitaly')
-rw-r--r-- | internal/gitaly/service/objectpool/create_test.go | 9 | ||||
-rw-r--r-- | internal/gitaly/service/objectpool/testhelper_test.go | 14 |
2 files changed, 21 insertions, 2 deletions
diff --git a/internal/gitaly/service/objectpool/create_test.go b/internal/gitaly/service/objectpool/create_test.go index f7dc13371..09ebca2a9 100644 --- a/internal/gitaly/service/objectpool/create_test.go +++ b/internal/gitaly/service/objectpool/create_test.go @@ -143,6 +143,8 @@ func TestDelete(t *testing.T) { cfg, repoProto, _, _, client := setup(ctx, t) repo := localrepo.NewTestRepo(t, cfg, repoProto) + repositoryClient := gitalypb.NewRepositoryServiceClient(extractConn(client)) + pool := initObjectPool(t, cfg, cfg.Storages[0]) _, err := client.CreateObjectPool(ctx, &gitalypb.CreateObjectPoolRequest{ ObjectPool: pool.ToProto(), @@ -203,7 +205,6 @@ func TestDelete(t *testing.T) { RelativePath: tc.relativePath, }, }}) - expectedErr := tc.error if tc.error == errInvalidPoolDir && testhelper.IsPraefectEnabled() { expectedErr = helper.ErrNotFound(fmt.Errorf( @@ -213,6 +214,12 @@ func TestDelete(t *testing.T) { } testhelper.RequireGrpcError(t, expectedErr, err) + + response, err := repositoryClient.RepositoryExists(ctx, &gitalypb.RepositoryExistsRequest{ + Repository: pool.ToProto().GetRepository(), + }) + require.NoError(t, err) + require.Equal(t, tc.error != nil, response.GetExists()) }) } } diff --git a/internal/gitaly/service/objectpool/testhelper_test.go b/internal/gitaly/service/objectpool/testhelper_test.go index f0ba73dd8..3ea7f981c 100644 --- a/internal/gitaly/service/objectpool/testhelper_test.go +++ b/internal/gitaly/service/objectpool/testhelper_test.go @@ -30,6 +30,18 @@ func TestMain(m *testing.M) { testhelper.Run(m) } +// clientWithConn allows for passing through the ClientConn to tests which need +// to access other services than ObjectPoolService. +type clientWithConn struct { + gitalypb.ObjectPoolServiceClient + conn *grpc.ClientConn +} + +// extractConn returns the underlying ClientConn from the client. +func extractConn(client gitalypb.ObjectPoolServiceClient) *grpc.ClientConn { + return client.(clientWithConn).conn +} + func setup(ctx context.Context, t *testing.T, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, storage.Locator, gitalypb.ObjectPoolServiceClient) { t.Helper() @@ -48,7 +60,7 @@ func setup(ctx context.Context, t *testing.T, opts ...testserver.GitalyServerOpt Seed: gittest.SeedGitLabTest, }) - return cfg, repo, repoPath, locator, gitalypb.NewObjectPoolServiceClient(conn) + return cfg, repo, repoPath, locator, clientWithConn{ObjectPoolServiceClient: gitalypb.NewObjectPoolServiceClient(conn), conn: conn} } func runObjectPoolServer(t *testing.T, cfg config.Cfg, locator storage.Locator, logger *logrus.Logger, opts ...testserver.GitalyServerOpt) string { |