Extract brew output parsing into BrewParser.swift (pure Swift, no AppKit) and add BrewBarTests target with 7 passing tests covering parseOutdated and parseVersion edge cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.1 KiB
Swift
40 lines
1.1 KiB
Swift
@testable import BrewBar
|
|
import XCTest
|
|
|
|
final class BrewParserTests: XCTestCase {
|
|
// MARK: - parseOutdated
|
|
|
|
func testParseOutdated_multiplePackages() {
|
|
let output = "wget\nffmpeg\ngit\n"
|
|
XCTAssertEqual(BrewParser.parseOutdated(output), ["wget", "ffmpeg", "git"])
|
|
}
|
|
|
|
func testParseOutdated_emptyOutput() {
|
|
XCTAssertEqual(BrewParser.parseOutdated(""), [])
|
|
}
|
|
|
|
func testParseOutdated_singlePackage() {
|
|
XCTAssertEqual(BrewParser.parseOutdated("wget\n"), ["wget"])
|
|
}
|
|
|
|
func testParseOutdated_trailingNewlinesIgnored() {
|
|
let output = "wget\n\n\n"
|
|
XCTAssertEqual(BrewParser.parseOutdated(output), ["wget"])
|
|
}
|
|
|
|
// MARK: - parseVersion
|
|
|
|
func testParseVersion_picksFirstLine() {
|
|
let output = "Homebrew 4.3.0\nHomebrew/homebrew-core (git revision abc123)\n"
|
|
XCTAssertEqual(BrewParser.parseVersion(output), "Homebrew 4.3.0")
|
|
}
|
|
|
|
func testParseVersion_emptyOutput() {
|
|
XCTAssertEqual(BrewParser.parseVersion(""), "Unknown")
|
|
}
|
|
|
|
func testParseVersion_singleLine() {
|
|
XCTAssertEqual(BrewParser.parseVersion("Homebrew 4.3.0"), "Homebrew 4.3.0")
|
|
}
|
|
}
|