Skip to content

Commit

Permalink
update tip kit tests
Browse files Browse the repository at this point in the history
update cloud kit container
  • Loading branch information
erolburak committed May 23, 2024
1 parent 44698fc commit cd9e3b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import CoreData

public final class PersistenceController {

// MARK: - Private Properties

private let container: NSPersistentContainer

// MARK: - Properties

public static let shared = PersistenceController()
Expand All @@ -22,8 +26,13 @@ public final class PersistenceController {
let managedObjectModel = NSManagedObjectModel(contentsOf: moduleUrl) else {
fatalError("Error initializing managed object model with module url!")
}
let container = NSPersistentCloudKitContainer(name: "BobbysNews",
managedObjectModel: managedObjectModel)
#if DEBUG
container = NSPersistentContainer(name: "BobbysNews",
managedObjectModel: managedObjectModel)
#else
container = NSPersistentCloudKitContainer(name: "BobbysNews",
managedObjectModel: managedObjectModel)
#endif
container.loadPersistentStores { _, error in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
Expand Down
14 changes: 11 additions & 3 deletions BobbysNewsTests/Presentation/ContentViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,21 @@ class ContentViewModelTests: XCTestCase {
XCTAssertEqual(sut.articles?.count, 1)
}

func testInvalidateSettingsTip() {
func testInvalidateSettingsTip() async {
// Given
let tipsStatus = Tips.Status.invalidated(.actionPerformed)
var tipsStatus: Tips.Status?
// When
let expectation = expectation(description: "Invalidate")
sut.invalidateSettingsTip()
for await status in sut.settingsTip.statusUpdates {
if status == .invalidated(.actionPerformed) {
tipsStatus = status
expectation.fulfill()
}
}
// Then
XCTAssertEqual(sut.settingsTip.status, tipsStatus)
await fulfillment(of: [expectation], timeout: 1)
XCTAssertNotNil(tipsStatus)
}

func testReset() {
Expand Down

0 comments on commit cd9e3b2

Please sign in to comment.