From ec63121c0e3fa1f71b766b9ca40080e9bd41ea01 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Wed, 28 Sep 2022 19:50:46 +0200
Subject: [PATCH] Remove facts from BackupParams

---
 .../XXMessengerClient/Utils/BackupParams.swift    |  8 +-------
 .../Functions/MessengerBackupParamsTests.swift    | 15 ++++-----------
 .../Functions/MessengerRestoreBackupTests.swift   |  6 +-----
 .../TestHelpers/TestDoubles.swift                 |  4 +---
 4 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/Sources/XXMessengerClient/Utils/BackupParams.swift b/Sources/XXMessengerClient/Utils/BackupParams.swift
index c3bd8fc0..8bf39a51 100644
--- a/Sources/XXMessengerClient/Utils/BackupParams.swift
+++ b/Sources/XXMessengerClient/Utils/BackupParams.swift
@@ -2,18 +2,12 @@ import Foundation
 
 public struct BackupParams: Equatable {
   public init(
-    username: String,
-    email: String?,
-    phone: String?
+    username: String
   ) {
     self.username = username
-    self.email = email
-    self.phone = phone
   }
 
   public var username: String
-  public var email: String?
-  public var phone: String?
 }
 
 extension BackupParams: Codable {
diff --git a/Tests/XXMessengerClientTests/Messenger/Functions/MessengerBackupParamsTests.swift b/Tests/XXMessengerClientTests/Messenger/Functions/MessengerBackupParamsTests.swift
index e0af7129..b65a34b9 100644
--- a/Tests/XXMessengerClientTests/Messenger/Functions/MessengerBackupParamsTests.swift
+++ b/Tests/XXMessengerClientTests/Messenger/Functions/MessengerBackupParamsTests.swift
@@ -15,16 +15,11 @@ final class MessengerBackupParamsTests: XCTestCase {
       return backup
     }
     let backup: MessengerBackupParams = .live(env)
-    let params = BackupParams(
-      username: "test-username",
-      email: "test-email",
-      phone: "test-phone"
-    )
 
-    try backup(params)
+    try backup(.stub)
 
     XCTAssertNoDifference(didAddJSON, [
-      String(data: try params.encode(), encoding: .utf8)!
+      String(data: try BackupParams.stub.encode(), encoding: .utf8)!
     ])
   }
 
@@ -32,9 +27,8 @@ final class MessengerBackupParamsTests: XCTestCase {
     var env: MessengerEnvironment = .unimplemented
     env.backup.get = { nil }
     let backup: MessengerBackupParams = .live(env)
-    let params = BackupParams(username: "test", email: nil, phone: nil)
 
-    XCTAssertThrowsError(try backup(params)) { error in
+    XCTAssertThrowsError(try backup(.stub)) { error in
       XCTAssertNoDifference(
         error as NSError,
         MessengerBackupParams.Error.notRunning as NSError
@@ -50,9 +44,8 @@ final class MessengerBackupParamsTests: XCTestCase {
       return backup
     }
     let backup: MessengerBackupParams = .live(env)
-    let params = BackupParams(username: "test", email: nil, phone: nil)
 
-    XCTAssertThrowsError(try backup(params)) { error in
+    XCTAssertThrowsError(try backup(.stub)) { error in
       XCTAssertNoDifference(
         error as NSError,
         MessengerBackupParams.Error.notRunning as NSError
diff --git a/Tests/XXMessengerClientTests/Messenger/Functions/MessengerRestoreBackupTests.swift b/Tests/XXMessengerClientTests/Messenger/Functions/MessengerRestoreBackupTests.swift
index 67663fee..672adc37 100644
--- a/Tests/XXMessengerClientTests/Messenger/Functions/MessengerRestoreBackupTests.swift
+++ b/Tests/XXMessengerClientTests/Messenger/Functions/MessengerRestoreBackupTests.swift
@@ -10,11 +10,7 @@ final class MessengerRestoreBackupTests: XCTestCase {
     let ndfData = "ndf-data".data(using: .utf8)!
     let password = "password".data(using: .utf8)!
     let backupContacts: [Data] = (1...3).map { "contact-\($0)" }.map { $0.data(using: .utf8)! }
-    let backupParams = BackupParams(
-      username: "backup-username",
-      email: "backup-email",
-      phone: "backup-phone"
-    )
+    let backupParams = BackupParams.stub
     let backupReport = BackupReport(
       restoredContacts: backupContacts,
       params: String(data: try! JSONEncoder().encode(backupParams), encoding: .utf8)!
diff --git a/Tests/XXMessengerClientTests/TestHelpers/TestDoubles.swift b/Tests/XXMessengerClientTests/TestHelpers/TestDoubles.swift
index 4d57e293..c9a90bde 100644
--- a/Tests/XXMessengerClientTests/TestHelpers/TestDoubles.swift
+++ b/Tests/XXMessengerClientTests/TestHelpers/TestDoubles.swift
@@ -20,8 +20,6 @@ extension Message {
 
 extension BackupParams {
   static let stub = BackupParams(
-    username: "stub-username",
-    email: "stub-email",
-    phone: "stub-phone"
+    username: "stub-username"
   )
 }
-- 
GitLab