Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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