Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Test that a Mail bundle is never offered while Mail is protected

Țugui Dragoșaef930da44de
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 2eb1d5e3..f53ada40 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -989,6 +989,22 @@ struct LeftoverScannerTests {
#expect(scan.leftovers.allSatisfy { $0.kind == .plugIns })
}
+ /// All of Mail in the home's Library is protected, so a Mail bundle is left out rather than offered and refused.
+ @Test func leavesOutTheAppsMailBundle() async throws {
+ let directory = try TemporaryDirectory()
+ let app = InstalledApp(
+ url: URL(filePath: "/Applications/Mailer.app"), bundleIdentifier: "org.example.mailer", name: "Mailer"
+ )
+ try directory.file(
+ "home/Library/Mail/Bundles/Mailer.mailbundle/Contents/Info.plist", contents: plist("org.example.mailer.bundle")
+ )
+ try directory.file("home/Library/Caches/org.example.mailer/blob")
+
+ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(app, installedApps: [app])
+
+ #expect(scan.leftovers.map(\.url.lastPathComponent) == ["org.example.mailer"])
+ }
+
/// A plug-in is named for what it does, so when its name matches nothing, the identifier in its `Info.plist`
/// is used instead. A match on the maker's prefix is only a guess, so the row is shown but never selected.
@Test func readsThePlugInsOwnIdentifierWhenItsNameSaysNothing() async throws {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index f5bb3c20..3cd9e7f7 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -529,6 +529,24 @@ struct OrphanScannerTests {
#expect(Set(scan.groups.flatMap(\.items).map(\.url.lastPathComponent)) == ["Gone.vst3", "Gone Reverb.component"])
}
+ @Test func leavesOutAMailBundleOfAnAppThatLeft() async throws {
+ let directory = try TemporaryDirectory()
+ let info = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <plist version="1.0"><dict><key>CFBundleIdentifier</key><string>org.example.mailer.bundle</string></dict></plist>
+ """
+ try directory.file("home/Library/Mail/Bundles/Mailer.mailbundle/Contents/Info.plist", contents: Data(info.utf8))
+ try directory.file("home/Library/Caches/org.example.mailer/blob")
+ let gone = RememberedApp(
+ bundleIdentifier: "org.example.mailer", name: "Mailer", teamIdentifier: nil, lastSeen: .now,
+ lastPath: "/Applications/Mailer.app"
+ )
+
+ let scan = await scanner(in: directory).scan(installedApps: installed, remembered: [gone])
+
+ #expect(scan.groups.flatMap(\.items).map(\.url.lastPathComponent) == ["org.example.mailer"])
+ }
+
/// Below the top of a place a dotted name is often a lock or a backup, so only what came with a gone app counts.
@Test func findsWhatAnAppThatLeftKeptInsideSomebodyElsesFolder() async throws {
let directory = try TemporaryDirectory()