Skip to content

Commit 6862576

Browse files
Add walkthrough comments explaining log-vs-failure for nil records
Explains why post-delete SOQL/SOSL verification uses NSLog instead of XCTAssertNotNil: delete already asserted success, queryAll verifies recycle bin, and these steps only check index consistency. A hard assertion caused ~1-in-10 CI flakes.
1 parent a8ba8e2 commit 6862576

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

libs/SalesforceSDKCore/SalesforceSDKCoreTests/SalesforceRestAPITests.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,23 +654,29 @@ - (void)testCreateQuerySearchDelete {
654654
}
655655
}
656656

657-
// well, let's do another query just to be sure — use retry since SOQL can briefly show stale results after delete
657+
// Post-delete verification: confirm SOQL no longer returns the record.
658+
// If records is nil, the server was unreachable during the entire polling window.
659+
// We log rather than fail because: (1) delete already asserted success in @finally above,
660+
// (2) queryAll below separately verifies the record is in the recycle bin, and
661+
// (3) this step only checks index consistency — not SDK correctness.
662+
// A hard assertion here caused ~1-in-10 CI flakes when SOQL was transiently unreachable.
658663
request = [[SFRestAPI sharedInstance] requestForQuery:[NSString stringWithFormat:@"select Id, FirstName from Contact where LastName='%@'", lastName] apiVersion:kSFRestDefaultAPIVersion];
659664
NSArray *records = [self sendSyncQueryRequestUntilEmpty:request maxWaitSeconds:30];
660665
if (records) {
661666
XCTAssertEqual((int)[records count], 0, @"expected no result");
662667
} else {
663668
NSLog(@"[testCreateQuerySearchDelete] SOQL poll never got a valid response — server may have been briefly unreachable during post-delete verification");
664669
}
665-
670+
666671
// check the deleted object is here
667672
request = [[SFRestAPI sharedInstance] requestForQueryAll:[NSString stringWithFormat:@"select Id, FirstName from Contact where LastName='%@'", lastName] apiVersion:kSFRestDefaultAPIVersion];
668673
response = [self sendSyncRequest:request];
669674
XCTAssertEqualObjects(response.returnStatus, kTestRequestStatusDidLoad, @"queryAll request failed");
670675
NSArray* records2 = ((NSDictionary *)response.dataResponse)[RECORDS];
671676
XCTAssertEqual((int)[records2 count], 1, @"expected just one query result");
672677

673-
// now search object — use retry since SOSL de-indexing has server-side lag
678+
// Post-delete SOSL verification: same rationale as SOQL above.
679+
// SOSL de-indexing has additional server-side lag beyond SOQL consistency.
674680
request = [[SFRestAPI sharedInstance] requestForSearch:[NSString stringWithFormat:@"Find {%@}", lastName] apiVersion:kSFRestDefaultAPIVersion];
675681
records = [self sendSyncSearchRequestUntilEmpty:request maxWaitSeconds:45];
676682
if (records) {

0 commit comments

Comments
 (0)