1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-28 06:50:08 +01:00

♻️ Improvements to Container

- RealShell is not reloaded during runtime (bugfix?)
- Container variables are now private(set)
- Initialization now also sets `webApi` property (new)
- It is only possible to run `bind` on a `Container` once now
  (previously known as `prepare`)
- Preparation for upcoming WebApi to replace `curl` command
  (for checking for updates)
This commit is contained in:
2025-11-18 12:04:37 +01:00
parent 58083ba443
commit 7a60435421
18 changed files with 152 additions and 134 deletions

View File

@@ -10,18 +10,26 @@ import Testing
import Foundation
struct TestableApiTest {
@Test func createFakeApi() {
let api = TestableApi(responses: [
url("https://api.phpmon.test"): FakeApiResponse(
private var container: Container
init() throws {
self.container = Container.fake(apiResponses: [
url("https://api.phpmon.test"): FakeWebApiResponse(
statusCode: 200,
headers: [:],
text: "{\"success\": true}"
)
])
}
#expect(api.hasResponse(for: url("https://api.phpmon.test")) == true)
var WebApi: TestableWebApi {
return container.webApi as! TestableWebApi
}
let response = api.getResponse(for: url("https://api.phpmon.test"))
@Test func createFakeApi() {
#expect(WebApi.hasResponse(for: url("https://api.phpmon.test")) == true)
let response = WebApi.getResponse(for: url("https://api.phpmon.test"))
#expect(response.statusCode == 200)
#expect(response.text.contains("success"))

View File

@@ -15,7 +15,7 @@ struct RealFileSystemTest {
init() throws {
let container = Container()
container.prepare()
container.bind()
filesystem = container.filesystem
}

View File

@@ -11,7 +11,8 @@ import Foundation
@Suite(.serialized)
struct TestableFileSystemTest {
var container: Container
private var container: Container
init() throws {
container = Container.fake(files: [
"/home/user/bin/foo": .fake(.binary),