2018-12-27 22:24:20 +00:00
|
|
|
//
|
2019-01-06 21:01:08 +00:00
|
|
|
// AppLibraryMock.swift
|
2024-10-01 18:05:41 +00:00
|
|
|
// masTests
|
2018-12-27 22:24:20 +00:00
|
|
|
//
|
|
|
|
// Created by Ben Chatelain on 12/27/18.
|
|
|
|
// Copyright © 2018 mas-cli. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-10-01 18:05:41 +00:00
|
|
|
@testable import mas
|
2018-12-27 22:24:20 +00:00
|
|
|
|
2019-01-06 21:01:08 +00:00
|
|
|
class AppLibraryMock: AppLibrary {
|
2024-10-20 12:09:01 +00:00
|
|
|
var installedApps: [SoftwareProduct] = []
|
2018-12-27 23:07:35 +00:00
|
|
|
|
2024-10-23 18:20:31 +00:00
|
|
|
func uninstallApps(atPaths appPaths: [String]) throws {
|
2018-12-27 23:07:35 +00:00
|
|
|
// Special case for testing where we pretend the trash command failed
|
2024-10-23 18:20:31 +00:00
|
|
|
if appPaths.contains("/dev/null") {
|
2024-10-23 18:11:52 +00:00
|
|
|
throw MASError.uninstallFailed(error: nil)
|
2018-12-27 23:07:35 +00:00
|
|
|
}
|
2018-12-27 22:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-28 22:08:31 +00:00
|
|
|
|
2024-09-16 10:52:16 +00:00
|
|
|
/// Members not part of the AppLibrary protocol that are only for test state management.
|
2019-01-06 21:01:08 +00:00
|
|
|
extension AppLibraryMock {
|
2018-12-28 22:08:31 +00:00
|
|
|
/// Clears out the list of installed apps.
|
|
|
|
func reset() {
|
|
|
|
installedApps = []
|
|
|
|
}
|
|
|
|
}
|