Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdchr committed May 30, 2022
1 parent 8c27b10 commit bf4c0c8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions WordPress/WordPressTest/ReminderScheduleCoordinatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,19 @@ private extension ReminderScheduleCoordinatorTests {
func makeAccountService() -> AccountService {
let service = AccountService(managedObjectContext: mainContext)
let account = service.createOrUpdateAccount(withUsername: "testuser", authToken: "authtoken")
account.defaultBlog = blog
account.primaryBlogID = blog.dotComID!
account.userID = NSNumber(value: 1)
service.setDefaultWordPressComAccount(account)

/// NOTE: When the whole suite is run, somehow the defaultWordPress account set here is wiped.
/// The account is created and stored successfully, but the UUID stored in the user defaults is somehow always nil.
///
/// The strangest thing is, it works just fine when this suite is run exclusively; but only fails when the whole suite is run.
/// My suspicion is that some part may have wiped the user defaults, resetting the default account to nil.
///
/// Until there's a better solution, setting the account UUID directly here seemed to fix the problem.
///
UserDefaults.standard.set(account.uuid, forKey: "AccountDefaultDotcomUUID")

return service
}

Expand Down

0 comments on commit bf4c0c8

Please sign in to comment.