github.com/sharovik/devbot@v1.0.1-0.20240308094637-4a0387c40516/test/mock/client/bitbucket.go (about) 1 package mock 2 3 import ( 4 "github.com/sharovik/devbot/internal/client" 5 "github.com/sharovik/devbot/internal/dto" 6 ) 7 8 type MockedBitBucketClient struct { 9 IsTokenInvalid bool 10 BeforeRequest error 11 LoadAuthToken error 12 13 PullRequestInfoResponse dto.BitBucketPullRequestInfoResponse 14 PullRequestInfoError error 15 16 MergePullRequestResponse dto.BitBucketPullRequestInfoResponse 17 MergePullRequestError error 18 19 CreateBranchResponse dto.BitBucketResponseBranchCreate 20 CreateBranchError error 21 22 ChangePullRequestDestinationResponse dto.BitBucketPullRequestInfoResponse 23 ChangePullRequestDestinationError error 24 25 CreatePullRequestResponse dto.BitBucketPullRequestInfoResponse 26 CreatePullRequestError error 27 28 RunPipelineResponse dto.BitBucketResponseRunPipeline 29 RunPipelineError error 30 } 31 32 func (b *MockedBitBucketClient) GetBranch(workspace string, repositorySlug string, branchName string) (dto.BitBucketResponseBranchCreate, error) { 33 panic("implement me") 34 } 35 36 func (b *MockedBitBucketClient) GetAuthToken() (string, error) { 37 panic("implement me") 38 } 39 40 func (b *MockedBitBucketClient) Init(client client.BaseHTTPClientInterface) { 41 42 } 43 44 func (b *MockedBitBucketClient) isTokenInvalid() bool { 45 return b.IsTokenInvalid 46 } 47 48 func (b *MockedBitBucketClient) beforeRequest() error { 49 return b.BeforeRequest 50 } 51 52 func (b *MockedBitBucketClient) loadAuthToken() error { 53 return b.LoadAuthToken 54 } 55 56 func (b *MockedBitBucketClient) PullRequestInfo(workspace string, repositorySlug string, pullRequestID int64) (dto.BitBucketPullRequestInfoResponse, error) { 57 return b.PullRequestInfoResponse, b.PullRequestInfoError 58 } 59 60 func (b *MockedBitBucketClient) MergePullRequest(workspace string, repositorySlug string, pullRequestID int64, description string, strategy string) (dto.BitBucketPullRequestInfoResponse, error) { 61 return b.MergePullRequestResponse, b.MergePullRequestError 62 } 63 64 func (b *MockedBitBucketClient) CreateBranch(workspace string, repositorySlug string, branchName string) (dto.BitBucketResponseBranchCreate, error) { 65 return b.CreateBranchResponse, b.CreateBranchError 66 } 67 68 func (b *MockedBitBucketClient) ChangePullRequestDestination(workspace string, repositorySlug string, pullRequestID int64, title string, branchName string) (dto.BitBucketPullRequestInfoResponse, error) { 69 return b.ChangePullRequestDestinationResponse, b.ChangePullRequestDestinationError 70 } 71 72 func (b *MockedBitBucketClient) CreatePullRequest(workspace string, repositorySlug string, request dto.BitBucketRequestPullRequestCreate) (dto.BitBucketPullRequestInfoResponse, error) { 73 return b.CreatePullRequestResponse, b.CreatePullRequestError 74 } 75 76 func (b *MockedBitBucketClient) RunPipeline(workspace string, repositorySlug string, request dto.BitBucketRequestRunPipeline) (dto.BitBucketResponseRunPipeline, error) { 77 return b.RunPipelineResponse, b.RunPipelineError 78 }