Skip to content
Snippets Groups Projects
Commit 4838dfdd authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add SetLogLevel functor

parent 784cf343
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings
public struct LogLevelConfigurator {
public var set: (LogLevel) throws -> Void
public func callAsFunction(logLevel: LogLevel) throws {
try set(logLevel)
}
}
extension LogLevelConfigurator {
public static let live = LogLevelConfigurator { logLevel in
var error: NSError?
let result = BindingsLogLevel(logLevel.rawValue, &error)
if let error = error {
throw error
}
if !result {
fatalError("BindingsLogLevel returned `false` without providing error")
}
}
}
#if DEBUG
extension LogLevelConfigurator {
public static let failing = LogLevelConfigurator { _ in
struct NotImplemented: Error {}
throw NotImplemented()
}
}
#endif
import Bindings
import XCTestDynamicOverlay
public struct SetLogLevel {
public var run: (LogLevel) throws -> Bool
public func callAsFunction(_ logLevel: LogLevel) throws -> Bool {
try run(logLevel)
}
}
extension SetLogLevel {
public static let live = SetLogLevel { logLevel in
var error: NSError?
let result = BindingsLogLevel(logLevel.rawValue, &error)
if let error = error {
throw error
}
return result
}
}
extension SetLogLevel {
public static let unimplemented = SetLogLevel(
run: XCTUnimplemented("\(Self.self)")
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment