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

CBL-5893: Throw exception for everything if finish() was successfully called beforehand #3302

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions Objective-C/Tests/VectorLazyIndexTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,10 @@ - (void) testIndexUpdaterIndexOutOfBounds {
* - Get the word string from the IndexUpdater.
* - Query the vector by word from the _default.words collection.
* - Convert the vector result which is an array object to a platform's float array.
* - Call setVector() with the platform's float array at the index..
* 8. Call finish() and check that the finish() is successfully called.
* 9. Call finish() again and check that a CouchbaseLiteException with the code NotOpen is thrown.
* - Call setVector() with the platform's float array at the index.
* 4. Call finish() and check that the finish() is successfully called.
* 5. Call finish() again and check that a CouchbaseLiteException with the code NotOpen is thrown.
* 6. Count, getValue, setVector, skipVector throw exception.
*/
- (void) testIndexUpdaterCallFinishTwice {
[self createWordsIndexWithConfig: LAZY_VECTOR_INDEX_CONFIG(@"word", 300, 8)];
Expand All @@ -1262,8 +1263,26 @@ - (void) testIndexUpdaterCallFinishTwice {
Assert([updater setVector: vector atIndex: 0 error: &error]);
Assert([updater finishWithError: &error]);

[self expectError: CBLErrorDomain code: CBLErrorNotOpen in: ^BOOL(NSError** err) {
return [updater finishWithError: err];
[self expectException: @"NSInternalInconsistencyException" in:^{
[updater count];
}];

[self expectException: @"NSInternalInconsistencyException" in:^{
[updater valueAtIndex: 0];
}];

[self expectException: @"NSInternalInconsistencyException" in:^{
NSError* outError;
[updater setVector: vector atIndex: 0 error: &outError];
}];

[self expectException: @"NSInternalInconsistencyException" in:^{
[updater skipVectorAtIndex: 0];
}];

[self expectException: @"NSInternalInconsistencyException" in:^{
NSError* outError;
[updater finishWithError: &outError];
}];
}

Expand Down
Loading