mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-12-21 03:10:06 +01:00
♻️ Reworked how getting a CaskFile via URL works
This commit is contained in:
@@ -27,7 +27,7 @@ struct CaskFileParserTest {
|
||||
}
|
||||
|
||||
@Test func can_extract_fields_from_cask_file() async throws {
|
||||
guard let caskFile = await CaskFile.from(container, url: CaskFileParserTest.exampleFilePath) else {
|
||||
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
|
||||
}
|
||||
@@ -53,7 +53,7 @@ struct CaskFileParserTest {
|
||||
@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 = await CaskFile.from(container, url: url) else {
|
||||
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
|
||||
}
|
||||
|
||||
41
tests/unit/Testables/WebApi/RealWebApiTest.swift
Normal file
41
tests/unit/Testables/WebApi/RealWebApiTest.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// RealWebApiTest.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 18/11/2025.
|
||||
// Copyright © 2025 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
|
||||
struct RealWebApiTest {
|
||||
private var container: Container
|
||||
|
||||
init() throws {
|
||||
self.container = Container()
|
||||
container.bind()
|
||||
}
|
||||
|
||||
var WebApi: RealWebApi {
|
||||
return container.webApi as! RealWebApi
|
||||
}
|
||||
|
||||
@Test func requestSucceeds() async {
|
||||
let response = try! await WebApi.get(
|
||||
url("https://api.phpmon.test/up")
|
||||
)
|
||||
|
||||
#expect(response.statusCode == 200)
|
||||
#expect(response.plainText!.contains("Response rendered in"))
|
||||
}
|
||||
|
||||
@Test func requestTimesOut() async {
|
||||
await #expect(throws: WebApiError.timedOut) {
|
||||
try await WebApi.get(
|
||||
url("https://api.phpmon.test/up"),
|
||||
withTimeout: .seconds(0.01)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user