Swift formatting

This commit is contained in:
Leif 2023-02-01 18:07:09 -07:00
parent 2663e6f541
commit 422c3e89f8
2 changed files with 12 additions and 13 deletions

View File

@ -21,4 +21,3 @@ extension ImmutablePlugin where Value == Input {
try await handle(value: value)
}
}

View File

@ -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)
}
}