1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-12-21 11:10:08 +01:00
Files
app/tests/unit/Parsers/CaskFileParserTest.swift
2025-12-02 15:21:05 +01:00

65 lines
1.9 KiB
Swift

//
// CaskFileParserTest.swift
// Unit Tests
//
// Created by Nico Verbruggen on 04/02/2023.
// Copyright © 2025 Nico Verbruggen. All rights reserved.
//
import Testing
import Foundation
struct CaskFileParserTest {
var container: Container
init() async throws {
container = Container.real(minimal: true)
}
var Shell: ShellProtocol {
return container.shell
}
// MARK: - Test Files
static var exampleFilePath: URL {
TestBundle.url(forResource: "phpmon-dev", withExtension: "rb")!
}
@Test func can_extract_fields_from_cask_file() async throws {
guard let caskFile = try? await CaskFile.fromUrl(container, CaskFileParserTest.exampleFilePath) else {
Issue.record("The CaskFile could not be parsed, check the log for more info")
return
}
#expect(
caskFile.version ==
"5.7.2_1035"
)
#expect(
caskFile.sha256 ==
"1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a"
)
#expect(
caskFile.name ==
"PHP Monitor DEV"
)
#expect(
caskFile.url ==
"https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon-dev.zip"
)
}
@Test func can_extract_fields_from_remote_cask_file() async throws {
let url = URL(string: "https://raw.githubusercontent.com/nicoverbruggen/homebrew-cask/master/Casks/phpmon.rb")!
guard let caskFile = try? await CaskFile.fromUrl(container, url) else {
Issue.record("The remote CaskFile could not be parsed, check the log for more info")
return
}
#expect(caskFile.properties.keys.contains("version"))
#expect(caskFile.properties.keys.contains("homepage"))
#expect(caskFile.properties.keys.contains("url"))
}
}