Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace handwriten mocks with mockery #3520

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

korniltsev
Copy link
Collaborator

No description provided.

@korniltsev korniltsev requested a review from a team as a code owner August 26, 2024 17:10
Comment on lines +225 to +235
bucket := mockobjstore.NewMockBucket(t)
bucket.On("Upload", mock.Anything, mock.MatchedBy(func(name string) bool {
return strings.HasSuffix(name, pathBlock)
}), mock.Anything).Return(nil)
bucket.On("Upload", mock.Anything, mock.MatchedBy(func(name string) bool {
return strings.Contains(name, pathDLQ)
}), mock.Anything).Return(fmt.Errorf("mock upload DLQ error"))
client := mockmetastorev1.NewMockMetastoreServiceClient(t)
client.On("AddBlock", mock.Anything, mock.Anything, mock.Anything).
Return(nil, fmt.Errorf("mock add block error"))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also want to specify whether each method (and how many times) was called and AssertExpectations in the end. Otherwise, if a method has not been called, the test will pass (unless you assert side-effects, which you do)

@korniltsev korniltsev merged commit 5c15835 into main Aug 27, 2024
18 checks passed
@korniltsev korniltsev deleted the korniltsev/segment_writer_mocks branch August 27, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants