Skip to content

Fixing tests in SalesforceSDKCore and MobileSync - #3914

Merged
wmathurin merged 5 commits into
forcedotcom:devfrom
wmathurin:dev
Sep 9, 2025
Merged

Fixing tests in SalesforceSDKCore and MobileSync#3914
wmathurin merged 5 commits into
forcedotcom:devfrom
wmathurin:dev

Conversation

@wmathurin

@wmathurin wmathurin commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

testRestCalls

I debugged and verified the same cache was being used across NSURLSession but there seems to be NSURLSession session-level cache partitioning that causes the second round of calls to miss. I decided to rewrite testRestCalls and use a test subclass of SFSDKEncryptedURLCache. testRestCalls sends actual requests to the server twice. After the first set of calls, we make sure the cache was written to. After the second set of calls, we make sure the cache was read from.

testInvalidAccessAndRefreshToken_MultipleRequests

Avoiding OAuth refresh double callback race condition:

  • Remove double failure block invocation when OAuth refresh fails
  • Call triggering request's failure block then remove from queue before flush

testUserAccountEncoding

Use consistent secure coding settings for both archiver and unarchiver to eliminate intermittent test failures with idData, customData, and accessScopes.

testStartFetchWithMaxTimestamp

Timestamp are rounded to the second so sleep so we need to sleep a bit before creating new accounts.

I debugged and verified the same cache was being used across NSURLSession but there seems to be NSURLSession session-level cache partitioning that causes the second round of calls to miss.
I decided to rewrite testRestCalls and use a test subclass of SFSDKEncryptedURLCache.
testRestCalls sends actual requests to the server twice. After the first set of calls, we make sure the cache was written to. After the second set of calls, we make sure the cache was read from.
@codecov

codecov Bot commented Sep 6, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.54%. Comparing base (170e47e) to head (d2ea3e3).
⚠️ Report is 12 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3914      +/-   ##
==========================================
+ Coverage   63.35%   63.54%   +0.18%     
==========================================
  Files         250      250              
  Lines       22504    22505       +1     
==========================================
+ Hits        14258    14301      +43     
+ Misses       8246     8204      -42     
Components Coverage Δ
Analytics 70.78% <ø> (ø)
Common 70.49% <ø> (ø)
Core 54.05% <100.00%> (+0.30%) ⬆️
SmartStore 73.66% <ø> (ø)
MobileSync 87.66% <ø> (ø)
Files with missing lines Coverage Δ
...Core/SalesforceSDKCore/Classes/RestAPI/SFRestAPI.m 89.36% <100.00%> (+0.23%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ipleRequests

Avoiding OAuth refresh double callback race condition:
- Remove double failure block invocation when OAuth refresh fails
- Call triggering request's failure block then remove from queue before flush
Use consistent secure coding settings for both archiver and unarchiver
to eliminate intermittent test failures with idData, customData, and accessScopes.
@wmathurin wmathurin changed the title Fix for failing testRestCalls Fixing tests testRestCalls / testInvalidAccessAndRefreshToken_MultipleRequests / testUserAccountEncoding) Sep 6, 2025
@github-actions

github-actions Bot commented Sep 6, 2025

Copy link
Copy Markdown
1 Warning
⚠️ Static Analysis found an issue with one or more files you modified. Please fix the issue(s).

Clang Static Analysis Issues

File Type Category Description Line Col
SFRestAPI Nullability Memory error nil assigned to a pointer which is expected to have non-null value 98 5

Generated by 🚫 Danger

@wmathurin

Copy link
Copy Markdown
Contributor Author

All the SalesforceSDKCore tests are passing again :-)

@wmathurin wmathurin changed the title Fixing tests testRestCalls / testInvalidAccessAndRefreshToken_MultipleRequests / testUserAccountEncoding) Fixing tests testRestCalls / testInvalidAccessAndRefreshToken_MultipleRequests / testUserAccountEncoding / testStartFetchWithMaxTimestamp() Sep 9, 2025
@wmathurin wmathurin changed the title Fixing tests testRestCalls / testInvalidAccessAndRefreshToken_MultipleRequests / testUserAccountEncoding / testStartFetchWithMaxTimestamp() Fixing tests in SalesforceSDKCore and MobileSync Sep 9, 2025
@wmathurin

Copy link
Copy Markdown
Contributor Author

There are a bunch of new failures on the last run due to - I'll try again in a while:

We can't save this record because the Account Flow process failed. Give your Salesforce admin these details. You've reached the limit of 10,000 notification actions per hour. Notification actions will start again in the next hour.

I've deactivated the flows in the org. I guess we should not setup flows that fire notifications on Account save in the same org we are running tests that create and update many Accounts!

@wmathurin
wmathurin merged commit 60679f6 into forcedotcom:dev Sep 9, 2025
32 of 35 checks passed
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