From ef518c4af3f2983bfbb156d1360da51c9dea80ff Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Thu, 21 Jul 2022 19:00:43 +0100
Subject: [PATCH] Add GenerateSecret functor

---
 ...wordGenerator.swift => GenerateSecret.swift} | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
 rename Sources/ElixxirDAppsSDK/{Legacy/PasswordGenerator.swift => GenerateSecret.swift} (51%)

diff --git a/Sources/ElixxirDAppsSDK/Legacy/PasswordGenerator.swift b/Sources/ElixxirDAppsSDK/GenerateSecret.swift
similarity index 51%
rename from Sources/ElixxirDAppsSDK/Legacy/PasswordGenerator.swift
rename to Sources/ElixxirDAppsSDK/GenerateSecret.swift
index 4c5b978e..3cf80be8 100644
--- a/Sources/ElixxirDAppsSDK/Legacy/PasswordGenerator.swift
+++ b/Sources/ElixxirDAppsSDK/GenerateSecret.swift
@@ -1,6 +1,7 @@
 import Bindings
+import XCTestDynamicOverlay
 
-public struct PasswordGenerator {
+public struct GenerateSecret {
   public var run: (Int) -> Data
 
   public func callAsFunction(numBytes: Int = 32) -> Data {
@@ -8,8 +9,8 @@ public struct PasswordGenerator {
   }
 }
 
-extension PasswordGenerator {
-  public static let live = PasswordGenerator { numBytes in
+extension GenerateSecret {
+  public static let live = GenerateSecret { numBytes in
     guard let secret = BindingsGenerateSecret(numBytes) else {
       fatalError("BindingsGenerateSecret returned `nil`")
     }
@@ -17,10 +18,8 @@ extension PasswordGenerator {
   }
 }
 
-#if DEBUG
-extension PasswordGenerator {
-  public static let failing = PasswordGenerator { _ in
-    fatalError("Not implemented")
-  }
+extension GenerateSecret {
+  public static let unimplemented = GenerateSecret(
+    run: XCTUnimplemented("\(Self.self)")
+  )
 }
-#endif
-- 
GitLab