Skip to content

Commit 39574c8

Browse files
committed
tests: clean up persistent temp directories
1 parent 7aa3924 commit 39574c8

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Tests/RAGKitTests/CoreDataVectorIndexTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,17 @@ final class CoreDataVectorIndexTests: XCTestCase {
318318
at: directory,
319319
withIntermediateDirectories: true
320320
)
321+
addTeardownBlock {
322+
do {
323+
try FileManager.default.removeItem(at: directory)
324+
} catch {
325+
XCTFail(
326+
"RAGKit could not remove a temporary Core Data vector index test directory at \(directory.path). \(error.localizedDescription)",
327+
file: file,
328+
line: line
329+
)
330+
}
331+
}
321332
} catch {
322333
XCTFail(
323334
"RAGKit could not create a temporary Core Data vector index test directory. \(error.localizedDescription)",

Tests/SwiftlyFetchTests/SwiftlyFetchLibraryTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ struct SwiftlyFetchLibraryTests {
308308
@Test("Persistent facade reopens conventional and semantic state")
309309
func persistentFacadeReopensConventionalAndSemanticState() async throws {
310310
let directory = try temporaryDirectory()
311+
defer {
312+
cleanupTemporaryDirectory(directory)
313+
}
311314

312315
do {
313316
let firstLibrary = try await SwiftlyFetchLibrary.macOSPersistentLibrary(at: directory)
@@ -332,6 +335,9 @@ struct SwiftlyFetchLibraryTests {
332335
@Test("Core Data semantic retry store reopens pending retries")
333336
func coreDataSemanticRetryStoreReopensPendingRetries() async throws {
334337
let directory = try temporaryDirectory()
338+
defer {
339+
cleanupTemporaryDirectory(directory)
340+
}
335341
let storeURL = directory.appendingPathComponent("SemanticRetries.sqlite")
336342
let olderDate = try #require(Calendar.current.date(from: DateComponents(year: 2026, month: 1, day: 1)))
337343
let newerDate = try #require(Calendar.current.date(from: DateComponents(year: 2026, month: 1, day: 2)))
@@ -493,4 +499,14 @@ private func temporaryDirectory() throws -> URL {
493499

494500
return directory
495501
}
502+
503+
private func cleanupTemporaryDirectory(_ directory: URL) {
504+
do {
505+
try FileManager.default.removeItem(at: directory)
506+
} catch {
507+
Issue.record(
508+
"SwiftlyFetch could not remove a temporary test directory at \(directory.path). \(error.localizedDescription)"
509+
)
510+
}
511+
}
496512
#endif

0 commit comments

Comments
 (0)