1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-13 14:30:06 +02:00

🏗 WIP: Shell rework

This commit is contained in:
2022-09-27 20:26:11 +02:00
parent 5399bddfeb
commit 3483569410
27 changed files with 93 additions and 87 deletions

View File

@@ -10,14 +10,14 @@ import XCTest
class ShellTest: XCTestCase {
func test_default_shell_is_system_shell() {
XCTAssertTrue(NxtShell.shared is SystemShell)
XCTAssertTrue(Shell is SystemShell)
XCTAssertTrue(NxtShell.shared.syncPipe("php -v")
XCTAssertTrue(Shell.syncPipe("php -v")
.contains("Copyright (c) The PHP Group"))
}
func test_system_shell_has_path() {
let systemShell = NxtShell.shared as! SystemShell
let systemShell = Shell as! SystemShell
XCTAssertTrue(systemShell.PATH.contains(":/usr/local/bin"))
XCTAssertTrue(systemShell.PATH.contains(":/usr/bin"))
@@ -38,15 +38,15 @@ class ShellTest: XCTestCase {
isError: false
)
NxtShell.useTestable([
ActiveShell.useTestable([
"php -v": expectedPhpOutput,
"php --version": slowVersionOutput
])
XCTAssertTrue(NxtShell.shared is TestableShell)
XCTAssertTrue(Shell is TestableShell)
XCTAssertEqual(expectedPhpOutput, NxtShell.shared.syncPipe("php -v"))
XCTAssertEqual(expectedPhpOutput, Shell.syncPipe("php -v"))
XCTAssertEqual(expectedPhpOutput, NxtShell.shared.syncPipe("php --version"))
XCTAssertEqual(expectedPhpOutput, Shell.syncPipe("php --version"))
}
}

View File

@@ -56,7 +56,7 @@ class HomebrewPackageTest: XCTestCase {
func testCanParseServicesJsonFromCliOutput() throws {
let services = try! JSONDecoder().decode(
[HomebrewService].self,
from: Shell.pipe(
from: LegacyShell.pipe(
"sudo \(Paths.brew) services info --all --json",
requiresPath: true
).data(using: .utf8)!
@@ -77,7 +77,7 @@ class HomebrewPackageTest: XCTestCase {
func testCanLoadExtensionJsonFromCliOutput() throws {
let package = try! JSONDecoder().decode(
[HomebrewPackage].self,
from: Shell.pipe("\(Paths.brew) info php --json", requiresPath: true).data(using: .utf8)!
from: LegacyShell.pipe("\(Paths.brew) info php --json", requiresPath: true).data(using: .utf8)!
).first!
XCTAssertTrue(package.name == "php")