-
Notifications
You must be signed in to change notification settings - Fork 140
DO NOT MERGE INTO 4.0: CBG-4862 force SendRev to check for errors #7762
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR refactors BLIP testing utilities to improve error handling and consistency. It creates explicit functions for testing expected conflicts and simplifies the SendRev
family of functions by removing error returns in favor of internal testify assertions.
- Introduces
SendRevExpectConflict
for explicit conflict testing scenarios - Refactors
SendRev
and related functions to handle errors internally using testify assertions - Adds comprehensive docstrings and moves error checking outside of return values
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
rest/utilities_testing.go | Major refactoring of BLIP testing functions with new error handling approach |
rest/blip_legacy_revid_test.go | Updated test calls to use new SendRev API and SendRevExpectConflict |
rest/blip_api_crud_test.go | Simplified test code by removing error handling for SendRev calls |
rest/blip_api_attachment_test.go | Updated attachment tests to use new SendRevWithAttachment API |
rest/user_api_test.go | Simplified ReadContinuousChanges usage |
rest/sync_fn_test.go | Updated WaitWithTimeout calls to new signature |
rest/importtest/import_test.go | Updated WaitWithTimeout calls to new signature |
rest/attachment_test.go | Updated SendRev calls to new API |
rest/api_test.go | Updated WaitWithTimeout calls to new signature |
rest/adminapitest/admin_api_test.go | Updated WaitWithTimeout calls to new signature |
rest/access_test.go | Updated SequenceForDoc calls to new API |
Comments suppressed due to low confidence (1)
rest/blip_api_crud_test.go:1
- The error variable used in the error message should be 'getAttachmentErr' instead of 'err' to match the actual error variable being checked.
/*
rest/utilities_testing.go
Outdated
} | ||
|
||
// NewRestTester returns a rest tester backed by a single database and a single default collection. | ||
// NewRestTesterDefaultCollection creates a rest tester backed by a single database and a single _default._deafult collection. |
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's a typo in the comment: '_deafult' should be '_default'.
// NewRestTesterDefaultCollection creates a rest tester backed by a single database and a single _default._deafult collection. | |
// NewRestTesterDefaultCollection creates a rest tester backed by a single database and a single _default._default collection. |
Copilot uses AI. Check for mistakes.
} | ||
|
||
// NewRestTester multiple collections a rest tester backed by a single database and any number of collections and the names of the keyspaces of collections created. | ||
// NewRestTesterMultipleCollections creates rest tester backed by a single database and any number of collections and the names of the keyspaces of collections created. |
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.
The comment is missing an article 'a' before 'rest tester' for grammatical correctness.
// NewRestTesterMultipleCollections creates rest tester backed by a single database and any number of collections and the names of the keyspaces of collections created. | |
// NewRestTesterMultipleCollections creates a rest tester backed by a single database and any number of collections and the names of the keyspaces of collections created. |
Copilot uses AI. Check for mistakes.
return sent, revRequest, revResponse, fmt.Errorf("Unexpected error sending rev: %v\n%s", errorCode, body) | ||
// SendRevWithHistory sends an unsolicited rev message and waits for the response. The docHistory should be in the same format as expected by db.PutExistingRevWithBody(), or empty if this is the first revision | ||
func (bt *BlipTester) SendRevWithHistory(docID, docRev string, revHistory []string, body []byte, properties blip.Properties) (res *blip.Message) { | ||
require.NotContains(bt.TB(), properties, "history", "If specifying history, use BlipTester.SendRev") |
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.
The error message suggests using 'BlipTester.SendRev' but the actual method name is 'SendRev'. Consider clarifying this refers to the SendRev method without history parameter.
require.NotContains(bt.TB(), properties, "history", "If specifying history, use BlipTester.SendRev") | |
require.NotContains(bt.TB(), properties, "history", "If specifying history, use BlipTester.SendRevWithHistory (not SendRev)") |
Copilot uses AI. Check for mistakes.
assert.True(t, sent) | ||
require.ErrorContains(t, err, "Document revision conflict") | ||
bt.SendRevExpectConflict("doc1", "3-def", []byte(`{"key": "val"}`), blip.Properties{db.RevMessageHistory: strings.Join(history, ",")}) | ||
//require.ErrorContains(t, err, "Document revision conflict") |
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.
This commented-out line should be removed as it's no longer needed with the new API.
//require.ErrorContains(t, err, "Document revision conflict") |
Copilot uses AI. Check for mistakes.
- Create SendRevExpectConflict to explicitly test for when a conflict is expected.
CBG-4862 force SendRev to check for errors
SendRev
to only return response, since that is the only value used.NOTE: This doesn't need to merge into 4.0 for release, so should wait until the release/4.0 branch is created.