PromtGarageMac / Tests /PromptGarageCoreTests /ActivityLoggerTests.swift
smlflg's picture
Initial public upload from Projekte/PromtGarageMac
4977db2 verified
Raw History Blame Contribute Delete
1.85 kB
import Foundation
import XCTest
@testable import PromptGarageCore
final class ActivityLoggerTests: XCTestCase {
func testImportLogOmitsSelectedPathAndPromptData() throws {
let directory = FileManager.default.temporaryDirectory
.appendingPathComponent("PromptGarageActivity-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
addTeardownBlock { try? FileManager.default.removeItem(at: directory) }
let logger = try ActivityLogger(logURL: directory.appendingPathComponent("activity.jsonl"))
var statistics = ImportStatistics()
statistics.scanned = 2
statistics.imported = 1
let preview = ImportPreview(
format: .geminiJSONL,
sourceURL: URL(fileURLWithPath: "/private/secret-project/customer-export.jsonl"),
candidates: [
ImportCandidate(
title: "Secret title",
content: "Secret prompt content that must never appear in the activity log",
source: "gemini-raw:0123456789ab",
tags: "private,customer",
model: nil
),
],
statistics: statistics
)
try logger.logImport(ImportReport(preview: preview, statistics: statistics))
let log = try String(contentsOf: logger.logURL, encoding: .utf8)
XCTAssertTrue(log.contains("import_completed"))
XCTAssertTrue(log.contains("gemini"))
XCTAssertFalse(log.contains("secret-project"))
XCTAssertFalse(log.contains("customer-export"))
XCTAssertFalse(log.contains("Secret title"))
XCTAssertFalse(log.contains("Secret prompt content"))
XCTAssertFalse(log.contains("private,customer"))
}
}