diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-11-26 15:08:21 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-12-01 17:12:07 +0300 |
commit | f1826df0476eef0c95538b7fc7be42afd084f215 (patch) | |
tree | 994a08d70e6d97457264ae25545f6bf4290f2a40 /internal/gitaly/service/operations/merge.go | |
parent | ff5805ed00db7003e9fcb06a8aee883616b090b6 (diff) |
operations: Expose server type to allow testing it
As we're about to change some implementation details of
`server.updateReferenceWithHooks()`, we want to add a set of tests which
verifies that our changes actually make sense. But the type is currently
private and thus not returned by `NewServer()`, which makes it hard to
wire up a test server.
Fix the issue by making exposing the type to other modules and returning
it from `NewServer()` directly, which allows us to test non-public
methods of that type.
Diffstat (limited to 'internal/gitaly/service/operations/merge.go')
-rw-r--r-- | internal/gitaly/service/operations/merge.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go index 06993c833..64c6ad276 100644 --- a/internal/gitaly/service/operations/merge.go +++ b/internal/gitaly/service/operations/merge.go @@ -16,7 +16,7 @@ import ( "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) -func (s *server) UserMergeBranch(bidi gitalypb.OperationService_UserMergeBranchServer) error { +func (s *Server) UserMergeBranch(bidi gitalypb.OperationService_UserMergeBranchServer) error { ctx := bidi.Context() if featureflag.IsEnabled(ctx, featureflag.GoUserMergeBranch) { @@ -95,7 +95,7 @@ func hookErrorFromStdoutAndStderr(sout string, serr string) string { return sout } -func (s *server) userMergeBranch(stream gitalypb.OperationService_UserMergeBranchServer) error { +func (s *Server) userMergeBranch(stream gitalypb.OperationService_UserMergeBranchServer) error { ctx := stream.Context() firstRequest, err := stream.Recv() @@ -195,7 +195,7 @@ func validateFFRequest(in *gitalypb.UserFFBranchRequest) error { return nil } -func (s *server) UserFFBranch(ctx context.Context, in *gitalypb.UserFFBranchRequest) (*gitalypb.UserFFBranchResponse, error) { +func (s *Server) UserFFBranch(ctx context.Context, in *gitalypb.UserFFBranchRequest) (*gitalypb.UserFFBranchResponse, error) { if err := validateFFRequest(in); err != nil { return nil, helper.ErrInvalidArgument(err) } @@ -257,7 +257,7 @@ func (s *server) UserFFBranch(ctx context.Context, in *gitalypb.UserFFBranchRequ }, nil } -func (s *server) userFFBranchRuby(ctx context.Context, in *gitalypb.UserFFBranchRequest) (*gitalypb.UserFFBranchResponse, error) { +func (s *Server) userFFBranchRuby(ctx context.Context, in *gitalypb.UserFFBranchRequest) (*gitalypb.UserFFBranchResponse, error) { client, err := s.ruby.OperationServiceClient(ctx) if err != nil { return nil, err @@ -298,7 +298,7 @@ func validateUserMergeToRefRequest(in *gitalypb.UserMergeToRefRequest) error { // userMergeToRef overwrites the given TargetRef to point to either Branch or // FirstParentRef. Afterwards, it performs a merge of SourceSHA with either // Branch or FirstParentRef and updates TargetRef to the merge commit. -func (s *server) userMergeToRef(ctx context.Context, request *gitalypb.UserMergeToRefRequest) (*gitalypb.UserMergeToRefResponse, error) { +func (s *Server) userMergeToRef(ctx context.Context, request *gitalypb.UserMergeToRefRequest) (*gitalypb.UserMergeToRefResponse, error) { repoPath, err := s.locator.GetPath(request.Repository) if err != nil { return nil, err @@ -357,7 +357,7 @@ func (s *server) userMergeToRef(ctx context.Context, request *gitalypb.UserMerge }, nil } -func (s *server) UserMergeToRef(ctx context.Context, in *gitalypb.UserMergeToRefRequest) (*gitalypb.UserMergeToRefResponse, error) { +func (s *Server) UserMergeToRef(ctx context.Context, in *gitalypb.UserMergeToRefRequest) (*gitalypb.UserMergeToRefResponse, error) { if err := validateUserMergeToRefRequest(in); err != nil { return nil, helper.ErrInvalidArgument(err) } |