Skip to content

Commit d71beac

Browse files
committed
Adjust the update method
1 parent 2b7bdee commit d71beac

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

WordPress/Classes/Services/GravatarService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Gravatar
88

99
public protocol GravatarImageUploader {
1010
@discardableResult
11-
func upload(_ image: UIImage, email: Email, accessToken: String) async throws -> URLResponse
11+
func upload(_ image: UIImage, selectionBehavior: AvatarSelection, accessToken: String) async throws -> AvatarType
1212
}
1313

1414
extension AvatarService: GravatarImageUploader { }
@@ -68,7 +68,7 @@ public class GravatarService {
6868

6969
Task {
7070
do {
71-
try await imageUploader.upload(image, email: Email(email), accessToken: accountToken)
71+
try await imageUploader.upload(image, selectionBehavior: .selectUploadedImage(for: Email(email)), accessToken: accountToken)
7272
DDLogInfo("GravatarService.uploadImage Success!")
7373
completion?(nil)
7474
} catch {

WordPress/WordPressTest/GravatarServiceTests.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ class GravatarServiceTests: CoreDataTestCase {
2020
}
2121
}
2222
}
23+
struct AvatarMock: AvatarType {
24+
var url: String
25+
var id: String
26+
}
2327

2428
class ImageServiceMock: GravatarImageUploader {
2529
var capturedAccountToken: String = ""
2630
var capturedAccountEmail: String = ""
27-
func upload(_ image: UIImage, email: Email, accessToken: String) async throws -> URLResponse {
28-
capturedAccountEmail = email.rawValue
31+
func upload(_ image: UIImage, selectionBehavior: AvatarSelection, accessToken: String) async throws -> AvatarType {
32+
switch selectionBehavior {
33+
case .selectUploadedImage(for: let email):
34+
capturedAccountEmail = email.rawValue
35+
default:
36+
break
37+
}
2938
capturedAccountToken = accessToken
30-
return URLResponse()
39+
return AvatarMock(url: "https://domain.com/avatar", id: "ID")
3140
}
3241
}
3342

0 commit comments

Comments
 (0)