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
No related branches found
No related tags found
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 ...@@ -2,23 +2,20 @@ import Bindings
import XCTestDynamicOverlay import XCTestDynamicOverlay
public struct GetNotificationsReport { public struct GetNotificationsReport {
public var run: (Int, String, MessageServiceList) throws -> NotificationReport public var run: (String, MessageServiceList) throws -> NotificationReport
public func callAsFunction( public func callAsFunction(
e2eId: Int,
notificationCSV: String, notificationCSV: String,
services: MessageServiceList services: MessageServiceList
) throws -> NotificationReport { ) throws -> NotificationReport {
try run(e2eId, notificationCSV, services) try run(notificationCSV, services)
} }
} }
extension GetNotificationsReport { extension GetNotificationsReport {
public static let live = GetNotificationsReport { public static let live = GetNotificationsReport { notificationCSV, services in
e2eId, notificationCSV, services in
var error: NSError? var error: NSError?
let result = BindingsGetNotificationsReport( let result = BindingsGetNotificationsReport(
e2eId,
notificationCSV, notificationCSV,
try services.encode(), try services.encode(),
&error &error
......
...@@ -3,7 +3,6 @@ import XCTestDynamicOverlay ...@@ -3,7 +3,6 @@ import XCTestDynamicOverlay
public struct MessengerGetNotificationReport { public struct MessengerGetNotificationReport {
public enum Error: Swift.Error, Equatable { public enum Error: Swift.Error, Equatable {
case notConnected
case serviceListMissing case serviceListMissing
} }
...@@ -17,14 +16,10 @@ public struct MessengerGetNotificationReport { ...@@ -17,14 +16,10 @@ public struct MessengerGetNotificationReport {
extension MessengerGetNotificationReport { extension MessengerGetNotificationReport {
public static func live(_ env: MessengerEnvironment) -> MessengerGetNotificationReport { public static func live(_ env: MessengerEnvironment) -> MessengerGetNotificationReport {
MessengerGetNotificationReport { notificationCSV in MessengerGetNotificationReport { notificationCSV in
guard let e2e = env.e2e() else {
throw Error.notConnected
}
guard let serviceList = env.serviceList() else { guard let serviceList = env.serviceList() else {
throw Error.serviceListMissing throw Error.serviceListMissing
} }
return try env.getNotificationsReport( return try env.getNotificationsReport(
e2eId: e2e.getId(),
notificationCSV: notificationCSV, notificationCSV: notificationCSV,
services: serviceList services: serviceList
) )
......
...@@ -6,30 +6,22 @@ import XXClient ...@@ -6,30 +6,22 @@ import XXClient
final class MessengerGetNotificationReportTests: XCTestCase { final class MessengerGetNotificationReportTests: XCTestCase {
func testGetReport() throws { func testGetReport() throws {
let e2eId = 123
let serviceList = MessageServiceList.stub() let serviceList = MessageServiceList.stub()
let notificationCSV = "notification-csv" let notificationCSV = "notification-csv"
let notificationReport = NotificationReport.stub() let notificationReport = NotificationReport.stub()
struct GetNotificationsReportParams: Equatable { struct GetNotificationsReportParams: Equatable {
var e2eId: Int
var notificationCSV: String var notificationCSV: String
var serviceList: MessageServiceList var serviceList: MessageServiceList
} }
var didGetNotificationsReport: [GetNotificationsReportParams] = [] var didGetNotificationsReport: [GetNotificationsReportParams] = []
var env: MessengerEnvironment = .unimplemented var env: MessengerEnvironment = .unimplemented
env.e2e.get = {
var e2e: E2E = .unimplemented
e2e.getId.run = { e2eId }
return e2e
}
env.serviceList.get = { env.serviceList.get = {
serviceList serviceList
} }
env.getNotificationsReport.run = { e2eId, notificationCSV, serviceList in env.getNotificationsReport.run = { notificationCSV, serviceList in
didGetNotificationsReport.append(.init( didGetNotificationsReport.append(.init(
e2eId: e2eId,
notificationCSV: notificationCSV, notificationCSV: notificationCSV,
serviceList: serviceList serviceList: serviceList
)) ))
...@@ -41,7 +33,6 @@ final class MessengerGetNotificationReportTests: XCTestCase { ...@@ -41,7 +33,6 @@ final class MessengerGetNotificationReportTests: XCTestCase {
XCTAssertNoDifference(didGetNotificationsReport, [ XCTAssertNoDifference(didGetNotificationsReport, [
.init( .init(
e2eId: e2eId,
notificationCSV: notificationCSV, notificationCSV: notificationCSV,
serviceList: serviceList serviceList: serviceList
) )
...@@ -49,19 +40,6 @@ final class MessengerGetNotificationReportTests: XCTestCase { ...@@ -49,19 +40,6 @@ final class MessengerGetNotificationReportTests: XCTestCase {
XCTAssertNoDifference(report, notificationReport) 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() { func testGetReportWhenServiceListMissing() {
var env: MessengerEnvironment = .unimplemented var env: MessengerEnvironment = .unimplemented
env.e2e.get = { .unimplemented } env.e2e.get = { .unimplemented }
......
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