Skip to content

Commit

Permalink
Renamed FUNSerializer to FunctionsSerializer (#13410)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakovmanshin authored Jul 27, 2024
1 parent af5efdb commit 26dab27
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion FirebaseFunctions/Sources/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum FunctionsConstants {
/// The projectID to use for all function references.
private let projectID: String
/// A serializer to encode/decode data and return values.
private let serializer = FUNSerializer()
private let serializer = FunctionsSerializer()
/// A factory for getting the metadata to include with function calls.
private let contextProvider: FunctionsContextProvider

Expand Down
2 changes: 1 addition & 1 deletion FirebaseFunctions/Sources/FunctionsError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ extension FunctionsErrorCode {

func FunctionsErrorForResponse(status: NSInteger,
body: Data?,
serializer: FUNSerializer) -> NSError? {
serializer: FunctionsSerializer) -> NSError? {
// Start with reasonable defaults from the status code.
var code = FunctionsCodeForHTTPStatus(status)
var description = code.descriptionForErrorCode
Expand Down
4 changes: 2 additions & 2 deletions FirebaseFunctions/Sources/Internal/FunctionsSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ private enum Constants {
static let dateType = "type.googleapis.com/google.protobuf.Timestamp"
}

extension FUNSerializer {
extension FunctionsSerializer {
enum Error: Swift.Error {
case unsupportedType(typeName: String)
case unknownNumberType(charValue: String, number: NSNumber)
case invalidValueForType(value: String, requestedType: String)
}
}

class FUNSerializer: NSObject {
class FunctionsSerializer: NSObject {
private let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import FirebaseCore

import XCTest

class SerializerTests: XCTestCase {
private var serializer: FUNSerializer!
class FunctionsSerializerTests: XCTestCase {
private var serializer: FunctionsSerializer!

override func setUp() {
super.setUp()
serializer = FUNSerializer()
serializer = FunctionsSerializer()
}

func testEncodeNull() throws {
Expand Down Expand Up @@ -98,7 +98,7 @@ class SerializerTests: XCTestCase {
let dictLowLong = ["@type": typeString, "value": badVal]
do {
_ = try serializer.decode(dictLowLong) as? NSNumber
} catch let FUNSerializer.Error.invalidValueForType(value, type) {
} catch let FunctionsSerializer.Error.invalidValueForType(value, type) {
XCTAssertEqual(value, badVal)
XCTAssertEqual(type, typeString)
return
Expand Down Expand Up @@ -136,7 +136,7 @@ class SerializerTests: XCTestCase {
let coded = ["@type": typeString, "value": tooHighVal]
do {
_ = try serializer.decode(coded) as? NSNumber
} catch let FUNSerializer.Error.invalidValueForType(value, type) {
} catch let FunctionsSerializer.Error.invalidValueForType(value, type) {
XCTAssertEqual(value, tooHighVal)
XCTAssertEqual(type, typeString)
return
Expand Down Expand Up @@ -241,7 +241,7 @@ class SerializerTests: XCTestCase {
let _ = try serializer.encode(input)
XCTFail("Expected an error")
} catch {
guard case let .unsupportedType(typeName: typeName) = error as? FUNSerializer.Error
guard case let .unsupportedType(typeName: typeName) = error as? FunctionsSerializer.Error
else {
return XCTFail("Unexpected error: \(error)")
}
Expand All @@ -257,7 +257,7 @@ class SerializerTests: XCTestCase {
let _ = try serializer.decode(input)
XCTFail("Expected an error")
} catch {
guard case let .unsupportedType(typeName: typeName) = error as? FUNSerializer.Error
guard case let .unsupportedType(typeName: typeName) = error as? FunctionsSerializer.Error
else {
return XCTFail("Unexpected error: \(error)")
}
Expand Down

0 comments on commit 26dab27

Please sign in to comment.