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

Add GenerateSecret functor

parent 4838dfdd
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings import Bindings
import XCTestDynamicOverlay
public struct PasswordGenerator { public struct GenerateSecret {
public var run: (Int) -> Data public var run: (Int) -> Data
public func callAsFunction(numBytes: Int = 32) -> Data { public func callAsFunction(numBytes: Int = 32) -> Data {
...@@ -8,8 +9,8 @@ public struct PasswordGenerator { ...@@ -8,8 +9,8 @@ public struct PasswordGenerator {
} }
} }
extension PasswordGenerator { extension GenerateSecret {
public static let live = PasswordGenerator { numBytes in public static let live = GenerateSecret { numBytes in
guard let secret = BindingsGenerateSecret(numBytes) else { guard let secret = BindingsGenerateSecret(numBytes) else {
fatalError("BindingsGenerateSecret returned `nil`") fatalError("BindingsGenerateSecret returned `nil`")
} }
...@@ -17,10 +18,8 @@ extension PasswordGenerator { ...@@ -17,10 +18,8 @@ extension PasswordGenerator {
} }
} }
#if DEBUG extension GenerateSecret {
extension PasswordGenerator { public static let unimplemented = GenerateSecret(
public static let failing = PasswordGenerator { _ in run: XCTUnimplemented("\(Self.self)")
fatalError("Not implemented") )
} }
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment