mirror of
https://github.com/mas-cli/mas
synced 2024-11-30 07:20:18 +00:00
aa0d204a07
https://www.swiftbysundell.com/posts/mocking-in-swift https://medium.com/@johnsundell/mocking-in-swift-56a913ee7484
30 lines
691 B
Swift
30 lines
691 B
Swift
//
|
|
// NetworkResult.swift
|
|
// MasKit
|
|
//
|
|
// Created by Ben Chatelain on 1/5/19.
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
//
|
|
|
|
enum NetworkResult {
|
|
case success(Data)
|
|
case failure(Error)
|
|
}
|
|
|
|
extension NetworkResult: Equatable {
|
|
static func == (lhs: NetworkResult, rhs: NetworkResult) -> Bool {
|
|
switch (lhs, rhs) {
|
|
case (let .success(data1), let .success(data2)):
|
|
return data1 == data2
|
|
|
|
case (let .failure(error1), let .failure(error2)):
|
|
return error1.localizedDescription == error2.localizedDescription
|
|
|
|
// case (.none, .none):
|
|
// return true
|
|
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
}
|