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

Remove e2eId param from GetNotificationsReport

parent b161cce8
Branches
Tags
2 merge requests!138Notifications,!102Release 1.0.0
This commit is part of merge request !138. Comments created here will be created in the context of that merge request.
......@@ -2,23 +2,20 @@ import Bindings
import XCTestDynamicOverlay
public struct GetNotificationsReport {
public var run: (Int, String, MessageServiceList) throws -> NotificationReport
public var run: (String, MessageServiceList) throws -> NotificationReport
public func callAsFunction(
e2eId: Int,
notificationCSV: String,
services: MessageServiceList
) throws -> NotificationReport {
try run(e2eId, notificationCSV, services)
try run(notificationCSV, services)
}
}
extension GetNotificationsReport {
public static let live = GetNotificationsReport {
e2eId, notificationCSV, services in
public static let live = GetNotificationsReport { notificationCSV, services in
var error: NSError?
let result = BindingsGetNotificationsReport(
e2eId,
notificationCSV,
try services.encode(),
&error
......
......@@ -3,7 +3,6 @@ import XCTestDynamicOverlay
public struct MessengerGetNotificationReport {
public enum Error: Swift.Error, Equatable {
case notConnected
case serviceListMissing
}
......@@ -17,14 +16,10 @@ public struct MessengerGetNotificationReport {
extension MessengerGetNotificationReport {
public static func live(_ env: MessengerEnvironment) -> MessengerGetNotificationReport {
MessengerGetNotificationReport { notificationCSV in
guard let e2e = env.e2e() else {
throw Error.notConnected
}
guard let serviceList = env.serviceList() else {
throw Error.serviceListMissing
}
return try env.getNotificationsReport(
e2eId: e2e.getId(),
notificationCSV: notificationCSV,
services: serviceList
)
......
......@@ -6,30 +6,22 @@ import XXClient
final class MessengerGetNotificationReportTests: XCTestCase {
func testGetReport() throws {
let e2eId = 123
let serviceList = MessageServiceList.stub()
let notificationCSV = "notification-csv"
let notificationReport = NotificationReport.stub()
struct GetNotificationsReportParams: Equatable {
var e2eId: Int
var notificationCSV: String
var serviceList: MessageServiceList
}
var didGetNotificationsReport: [GetNotificationsReportParams] = []
var env: MessengerEnvironment = .unimplemented
env.e2e.get = {
var e2e: E2E = .unimplemented
e2e.getId.run = { e2eId }
return e2e
}
env.serviceList.get = {
serviceList
}
env.getNotificationsReport.run = { e2eId, notificationCSV, serviceList in
env.getNotificationsReport.run = { notificationCSV, serviceList in
didGetNotificationsReport.append(.init(
e2eId: e2eId,
notificationCSV: notificationCSV,
serviceList: serviceList
))
......@@ -41,7 +33,6 @@ final class MessengerGetNotificationReportTests: XCTestCase {
XCTAssertNoDifference(didGetNotificationsReport, [
.init(
e2eId: e2eId,
notificationCSV: notificationCSV,
serviceList: serviceList
)
......@@ -49,19 +40,6 @@ final class MessengerGetNotificationReportTests: XCTestCase {
XCTAssertNoDifference(report, notificationReport)
}
func testGetReportWhenNotConnected() {
var env: MessengerEnvironment = .unimplemented
env.e2e.get = { nil }
let getReport: MessengerGetNotificationReport = .live(env)
XCTAssertThrowsError(try getReport(notificationCSV: "")) { error in
XCTAssertNoDifference(
error as? MessengerGetNotificationReport.Error,
.notConnected
)
}
}
func testGetReportWhenServiceListMissing() {
var env: MessengerEnvironment = .unimplemented
env.e2e.get = { .unimplemented }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment