Skip to content

Commit

Permalink
Use ImageCache.shared as the default value (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol authored Sep 10, 2024
1 parent 337a2b6 commit 08c63e5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct ImageDownloadService: ImageDownloader, Sendable {
/// - cache: A type which will perform image caching operations.
public init(client: HTTPClient? = nil, cache: ImageCaching? = nil) {
self.client = client ?? URLSessionHTTPClient()
self.imageCache = cache ?? ImageCache()
self.imageCache = cache ?? ImageCache.shared
}

public func fetchImage(with url: URL, forceRefresh: Bool = false, processingMethod: ImageProcessingMethod = .common()) async throws -> ImageDownloadResult {
Expand Down
2 changes: 1 addition & 1 deletion Tests/GravatarTests/AvatarServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class AvatarServiceTests: XCTestCase {
func testFetchImage() async throws {
let response = HTTPURLResponse.successResponse(with: TestData.urlFromEmail)
let sessionMock = URLSessionMock(returnData: ImageHelper.testImageData, response: response)
let service = avatarService(with: sessionMock)
let service = avatarService(with: sessionMock, cache: TestImageCache())
let options = ImageDownloadOptions()

let imageResponse = try await service.fetch(with: .email(TestData.email), options: options)
Expand Down
2 changes: 1 addition & 1 deletion Tests/GravatarTests/ImageDownloadServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class ImageDownloadServiceTests: XCTestCase {
let imageURL = "https://gravatar.com/avatar/HASH"
let response = HTTPURLResponse.successResponse(with: URL(string: imageURL)!)
let sessionMock = URLSessionMock(returnData: ImageHelper.testImageData, response: response)
let service = imageDownloadService(with: sessionMock)
let service = imageDownloadService(with: sessionMock, cache: TestImageCache())

let imageResponse = try await service.fetchImage(with: URL(string: imageURL)!)
let request = await sessionMock.request
Expand Down
2 changes: 1 addition & 1 deletion version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Gravatar
VERSION = '2.1.0'.freeze
VERSION = '2.1.1'.freeze
end

0 comments on commit 08c63e5

Please sign in to comment.