SPB Git

spb/poche Public

Agent personnel 100 % on-device — SwiftUI + Apple Foundation Models + EventKit + SwiftData. Aucune API, aucun serveur.

Swift 100%
2.1 KB · 63 lines swift
Raw Blame History
1//2//  SharedInboxTests.swift3//  PocheTests4//5//  Author:  Simon-Pierre Boucher6//  Contact: contact@spboucher.ai7//89import Foundation10import SwiftData11import Testing12@testable import Poche1314@MainActor15struct SharedInboxTests {16    private func temporaryInboxURL() -> URL {17        FileManager.default.temporaryDirectory18            .appendingPathComponent("inbox-\(UUID().uuidString).json")19    }2021    @Test func appendThenDrainRoundTrips() {22        let url = temporaryInboxURL()23        defer { try? FileManager.default.removeItem(at: url) }2425        SharedInbox.append(SharedInboxItem(title: "Lien", content: "https://exemple.fr", date: .now), at: url)26        SharedInbox.append(SharedInboxItem(title: "Texte", content: "Un extrait partagé", date: .now), at: url)2728        let drained = SharedInbox.drain(at: url)29        #expect(drained.count == 2)30        #expect(drained.first?.title == "Lien")31        // Draining empties the inbox.32        #expect(SharedInbox.drain(at: url).isEmpty)33    }3435    @Test func importCreatesNotesFromInbox() throws {36        let url = temporaryInboxURL()37        defer { try? FileManager.default.removeItem(at: url) }3839        SharedInbox.append(SharedInboxItem(title: "Article", content: "À lire plus tard", date: .now), at: url)4041        let container = try ModelContainer(42            for: Note.self, TaskItem.self, ConversationRecord.self, TurnRecord.self,43            configurations: ModelConfiguration(isStoredInMemoryOnly: true)44        )45        let store = PocheStore(container: container)46        store.importSharedInbox(from: url)4748        let corpus = store.corpus()49        #expect(corpus.contains { $0.kind == "note" && $0.title == "Article" })50    }5152    @Test func missingInboxIsHarmless() throws {53        let container = try ModelContainer(54            for: Note.self, TaskItem.self, ConversationRecord.self, TurnRecord.self,55            configurations: ModelConfiguration(isStoredInMemoryOnly: true)56        )57        let store = PocheStore(container: container)58        store.importSharedInbox(from: nil)59        store.importSharedInbox(from: temporaryInboxURL())60        #expect(store.corpus().isEmpty)61    }62}63