Added MediaProvider tests (#386)

* Media provider tests

* Moved classes to separate files

* Moved image file

* Removed unused image file

* Rebase and refactor.

Replace removed error type.
Refactor XYZMock to MockXYZ.

Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
Aleksandrs Proskurins
2023-01-05 20:20:49 +02:00
committed by GitHub
parent e4d087a0a4
commit e573bc0dd2
12 changed files with 456 additions and 12 deletions
@@ -20,12 +20,12 @@ import UIKit
struct MediaProvider: MediaProviderProtocol {
private let mediaProxy: MediaProxyProtocol
private let imageCache: Kingfisher.ImageCache
private let fileCache: FileCache
private let fileCache: FileCacheProtocol
private let backgroundTaskService: BackgroundTaskServiceProtocol?
init(mediaProxy: MediaProxyProtocol,
imageCache: Kingfisher.ImageCache,
fileCache: FileCache,
fileCache: FileCacheProtocol,
backgroundTaskService: BackgroundTaskServiceProtocol?) {
self.mediaProxy = mediaProxy
self.imageCache = imageCache
@@ -54,7 +54,7 @@ class UserSessionStore: UserSessionStoreProtocol {
return .success(UserSession(clientProxy: clientProxy,
mediaProvider: MediaProvider(mediaProxy: clientProxy,
imageCache: .onlyInMemory,
fileCache: .default,
fileCache: FileCache.default,
backgroundTaskService: backgroundTaskService)))
case .failure(let error):
MXLog.error("Failed restoring login with error: \(error)")
@@ -73,7 +73,7 @@ class UserSessionStore: UserSessionStoreProtocol {
return .success(UserSession(clientProxy: clientProxy,
mediaProvider: MediaProvider(mediaProxy: clientProxy,
imageCache: .onlyInMemory,
fileCache: .default,
fileCache: FileCache.default,
backgroundTaskService: backgroundTaskService)))
case .failure(let error):
MXLog.error("Failed creating user session with error: \(error)")