1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-07 21:20:07 +01:00

🚧 Add fake API abstraction

This commit is contained in:
2025-09-29 13:40:01 +02:00
parent 17b002f0ab
commit 9c9720de42
5 changed files with 146 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
//
// Untitled.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 29/09/2025.
// Copyright © 2025 Nico Verbruggen. All rights reserved.
//
import Testing
import Foundation
@Suite("Api")
struct TestableApiTest {
@Test
func createFakeApi() {
let api = TestableApi(responses: [
url("https://api.phpmon.test"): FakeApiResponse(statusCode: 200, headers: [:], text: "{\"success\": true}")
])
#expect(api.hasResponse(for: url("https://api.phpmon.test")) == true)
let response = api.getResponse(for: url("https://api.phpmon.test"))
#expect(response.statusCode == 200)
#expect(response.text.contains("success"))
}
}