-
Notifications
You must be signed in to change notification settings - Fork 409
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
Fix tests to assert correct error #2546
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2546 +/- ##
==========================================
+ Coverage 66.19% 66.21% +0.01%
==========================================
Files 429 429
Lines 20954 20963 +9
==========================================
+ Hits 13870 13880 +10
+ Misses 6150 6148 -2
- Partials 934 935 +1
... and 2 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. |
findAndMofidy
error typeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
integration/helpers.go
Outdated
// driver sent an error which is not WriteException, check errors are the same. | ||
assert.Equal(t, expected, actual) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would happily allow AssertMatchesWriteError(t, io.EOF, io.EOF)
, but that contradicts the function description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated function description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, currently I'm seeing error from the driver that update needs to have at least one field and cannot be empty. I guess we are testing that in few tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AssertMatchesWriteError
should check that both errors are WriteError
s (wrapped in WriteException
s). It should not consider other error types to be acceptable. That what was wrong in the previous code and what is still wrong now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to assert only for WriteError
. For ReplaceEmptyDocument
test, given the error comes from mongo go driver https://github.com/mongodb/mongo-go-driver/blob/master/mongo/mongo.go#L158, not sure if we want to test driver errors. But for now, I'm checking that specific error message for target and compat before calling WriteError
.
FerretDB/integration/update_compat_test.go
Line 435 in bab38ae
"ReplaceEmptyDocument": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Are we planning to introduce comparison of messages in the future? To stay independent from data we can use regexes or replace the values with placeholders before comparison
@noisersup we have this issue: #2599 :) |
34e85be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice catch with multi
flag!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The checks look reasonable!
I'm not sure about the naming (left a suggestion about naming), but I don't really like my suggestion as the functions have different signatures (different error types).
7836630
Description
Closes #2545.
Closes #2345.
Readiness checklist
task all
, and it passed.@FerretDB/core
), Labels, Project and project's Sprint fields.