Skip to content

Commit

Permalink
Add test for files backend song scan cancelling
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Apr 12, 2024
1 parent 7e2675f commit 55169b6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions HarmonyKitTests/Backend/Files/FilesBackendTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,20 @@ class FilesBackendTests: XCTestCase {
semaphore.wait()
}
}

func testScanCancel() throws {
try createTemporaryDirectoryStructure()
let backend = FilesBackend(path: temporaryDirectory, backendId: "test-be")
Task {
try await backend.scan(
containerScanApprover: { _,_ in return true },
songScanApprover: { _,_ in return true },
finalisedSongHandler: { song in self.songs.append(song) },
finalisedContainerHandler: { _,_ in }
)
}
backend.cancelScan()
XCTAssertFalse(backend.presentation.scanning, "Expected scanning to be false")
XCTAssertNotEqual(songs.count, 3, "All songs should not have been scanned")
}
}

0 comments on commit 55169b6

Please sign in to comment.