From 2eb1a9b8dcc102c0d2aaf7d83135eec82802085f Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Tue, 10 Dec 2024 14:51:59 -0600 Subject: [PATCH] Remove unused queryItem --- Sources/Gravatar/Network/Services/ProfileService.swift | 4 +--- Tests/GravatarUITests/AvatarPickerViewModelTests.swift | 9 ++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Sources/Gravatar/Network/Services/ProfileService.swift b/Sources/Gravatar/Network/Services/ProfileService.swift index 0cd18f5f..0f1bdf73 100644 --- a/Sources/Gravatar/Network/Services/ProfileService.swift +++ b/Sources/Gravatar/Network/Services/ProfileService.swift @@ -70,9 +70,7 @@ public struct ProfileService: ProfileFetching, Sendable { for avatar: AvatarIdentifier, token: String ) async throws -> Avatar { - guard let url = avatarsBaseURLComponents - .settingQueryItems([.init(name: "rating", value: rating.rawValue)]).url? - .appendingPathComponent(avatar.id) + guard let url = avatarsBaseURLComponents.url?.appendingPathComponent(avatar.id) else { throw APIError.requestError(reason: .urlInitializationFailed) } diff --git a/Tests/GravatarUITests/AvatarPickerViewModelTests.swift b/Tests/GravatarUITests/AvatarPickerViewModelTests.swift index 4571bba6..0b56b0b7 100644 --- a/Tests/GravatarUITests/AvatarPickerViewModelTests.swift +++ b/Tests/GravatarUITests/AvatarPickerViewModelTests.swift @@ -274,10 +274,6 @@ final class URLSessionAvatarPickerMock: URLSessionProtocol { case avatars } - enum QueryType: String { - case rating - } - init(returnErrorCode: Int? = nil) { self.returnErrorCode = returnErrorCode } @@ -313,7 +309,10 @@ final class URLSessionAvatarPickerMock: URLSessionProtocol { private func isSetAvatarRatingRequest(_ request: URLRequest) -> Bool { guard request.httpMethod == "PATCH", request.url?.absoluteString.contains(RequestType.avatars.rawValue) == true, - request.url?.query?.contains(QueryType.rating.rawValue) == true + let bodyData = request.httpBody, + let updateAvatarRequestBody = try? JSONDecoder().decode(UpdateAvatarRequest.self, from: bodyData), + updateAvatarRequestBody.rating != nil + else { return false }