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.

1.4 KB
Raw Blame
import Foundation
@testable import Peel
import PeelCore
import Testing

struct MovesHeldTests {
    private static let full = HistoryWriteProblem.diskFull(free: 1_000, needed: 1_000_002)

    @Test func namesWhatKeepsEveryMoveBack() {
        func reason(_ exclusions: Bool, _ history: Bool, _ writing: Bool) -> MovesHeld? {
            MovesHeld.reason(
                exclusionsUnreadable: exclusions, historyUnreadable: history ? .notAFile : nil,
                historyUnwritable: writing ? Self.full : nil
            )
        }

        #expect(reason(false, false, false) == nil)
        #expect(reason(true, true, true) == .exclusionsUnreadable)
        #expect(reason(false, true, true) == .historyUnreadable(.notAFile))
        #expect(reason(false, false, true) == .historyUnwritable(Self.full))
    }

    @Test func anActionHistoryDoesntRecordWaitsOnlyForTheExclusions() {
        func reason(_ exclusions: Bool, _ history: Bool, _ writing: Bool) -> MovesHeld? {
            MovesHeld.reason(
                exclusionsUnreadable: exclusions, historyUnreadable: history ? .notAFile : nil,
                historyUnwritable: writing ? Self.full : nil, recordsInHistory: false
            )
        }

        #expect(reason(false, true, false) == nil)
        #expect(reason(false, false, true) == nil)
        #expect(reason(true, true, true) == .exclusionsUnreadable)
    }
}