Swift formatting
This commit is contained in:
parent
2663e6f541
commit
422c3e89f8
|
@ -21,4 +21,3 @@ extension ImmutablePlugin where Value == Input {
|
|||
try await handle(value: value)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,42 +86,42 @@ final class PluginTests: XCTestCase {
|
|||
let token = try XCTUnwrap(urlRequest.request.allHTTPHeaderFields)["auth"]
|
||||
XCTAssertEqual(token, "token")
|
||||
}
|
||||
|
||||
|
||||
func testImmutablePlugin() async throws {
|
||||
class MockService: Pluginable {
|
||||
var plugins: [any Plugin] = []
|
||||
}
|
||||
|
||||
|
||||
class CountPlugin: ImmutablePlugin {
|
||||
typealias Source = MockService
|
||||
|
||||
|
||||
static let shared = CountPlugin()
|
||||
|
||||
var count: Int = 0
|
||||
|
||||
private init() {}
|
||||
|
||||
|
||||
func handle(value: Void) async throws {
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let service = MockService()
|
||||
|
||||
|
||||
XCTAssertEqual(service.pluginTypes, [])
|
||||
|
||||
|
||||
service.register(
|
||||
plugin: CountPlugin.shared
|
||||
)
|
||||
|
||||
|
||||
XCTAssertEqual(service.pluginTypes, ["(input: (), output: ())"])
|
||||
|
||||
|
||||
try await service.handle(value: "Woot")
|
||||
|
||||
|
||||
XCTAssertEqual(CountPlugin.shared.count, 0)
|
||||
|
||||
|
||||
try await service.handle()
|
||||
|
||||
|
||||
XCTAssertEqual(CountPlugin.shared.count, 1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue