^ Testing

This commit is contained in:
David Bureš 2025-12-09 21:38:43 +01:00
parent 79b6ddaf55
commit f4576e88b4
No known key found for this signature in database
1 changed files with 24 additions and 8 deletions

View File

@ -1,5 +1,8 @@
import Testing
import Foundation
import CorkShared
import CorkModels
import CorkTerminalFunctions
@Suite("Tap Decoding")
struct TapDecodingTest
@ -39,14 +42,22 @@ struct TapDecodingTest
}
]
"""
let decodedTapInfo = try? await parseTapInfo(from: demoData)
guard let tapInfoAsData: Data = demoData.data(using: .utf8) else
{
fatalError("Couldn't convert the demo data from String to Data - the testing environment is fucked")
}
#expect(decodedTapInfo?.name == "marsanne/cask")
#expect(decodedTapInfo?.user == "marsanne")
#expect(decodedTapInfo?.installed == true)
#expect(decodedTapInfo?.path.absoluteString == "/opt/homebrew/Library/Taps/marsanne/homebrew-cask")
#expect(decodedTapInfo?.caskTokens.count == 2)
#expect(decodedTapInfo?.caskFiles?.count == 2)
guard let decodedTapInfo: TapInfo = try? await .init(from: tapInfoAsData) else
{
fatalError("Couldn't init the TapInfo struct from the provided data")
}
#expect(decodedTapInfo.name == "marsanne/cask")
#expect(decodedTapInfo.user == "marsanne")
#expect(decodedTapInfo.installed == true)
#expect(decodedTapInfo.path.absoluteString == "/opt/homebrew/Library/Taps/marsanne/homebrew-cask")
#expect(decodedTapInfo.caskTokens.count == 2)
#expect(decodedTapInfo.caskFiles?.count == 2)
}
@Test("Decode Core Tap")
@ -69,6 +80,11 @@ struct TapDecodingTest
{
let coreTapRawOutput: String = await shell(AppConstants.shared.brewExecutablePath, ["tap-info", "--json", tapName]).standardOutput
return try? await parseTapInfo(from: coreTapRawOutput)
guard let tapInfoAsData: Data = coreTapRawOutput.data(using: .utf8) else
{
fatalError("Couldn't convert the demo data from String to Data - the testing environment is fucked")
}
return try? await .init(from: tapInfoAsData)
}
}