mirror of
https://github.com/Aminark/legado-ios.git
synced 2026-10-24 04:41:23 +08:00
feat: open-source 小浣熊阅读 for iOS
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import LegadoCore
|
||||
|
||||
struct BookRepositoryTests {
|
||||
@Test func persistsBooksAtomically() async throws {
|
||||
let directory = FileManager.default.temporaryDirectory
|
||||
.appending(path: UUID().uuidString, directoryHint: .isDirectory)
|
||||
let fileURL = directory.appending(path: "books.json")
|
||||
defer { try? FileManager.default.removeItem(at: directory) }
|
||||
let repository = FileBookRepository(fileURL: fileURL)
|
||||
var book = Book(bookUrl: "https://example.test/book/1", name: "测试书", author: "作者", origin: "https://example.test")
|
||||
book.durChapterIndex = 3
|
||||
|
||||
try await repository.save([book])
|
||||
let restored = try await repository.load()
|
||||
|
||||
#expect(restored == [book])
|
||||
#expect(restored.first?.durChapterIndex == 3)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user