Skip to content

Commit

Permalink
Fixing for force_unwrapping in some places + HTTPFileTask
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Apr 2, 2024
1 parent e6d10a4 commit 41c5faf
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions PubNubMembership/Tests/MembershipTestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extension EndpointResponse where Value == Data {
init(data: Data?) {
self.init(
router: MockRouter(),
// swiftlint:disable:next force_unwrapping
request: .init(url: URL(string: "example.com")!),
response: .init(),
payload: data ?? Data()
Expand Down
1 change: 1 addition & 0 deletions PubNubSpace/Tests/SpaceTestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extension EndpointResponse where Value == Data {
init(data: Data?) {
self.init(
router: MockRouter(),
// swiftlint:disable:next force_unwrapping
request: .init(url: URL(string: "example.com")!),
response: .init(),
payload: data ?? Data()
Expand Down
4 changes: 2 additions & 2 deletions PubNubUser/Tests/Test+PubNubUserPatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class PubNubUserPatcherTests: XCTestCase {
eTag: "OldETag"
)

// swiftlint:disable:next force_unwrapping
var patcher = PubNubUser.Patcher(
id: "TestUserId",
updated: .distantFuture,
Expand All @@ -36,6 +35,7 @@ class PubNubUserPatcherTests: XCTestCase {
type: .some("TestType"),
status: .some("TestStatus"),
externalId: .some("TestExternalId"),
// swiftlint:disable:next force_unwrapping
profileURL: .some(URL(string: "http://example.com")!),
email: .some("TestEmail"),
custom: .some(UserCustom(value: "Tester"))
Expand All @@ -54,7 +54,6 @@ class PubNubUserPatcherTests: XCTestCase {
eTag: "TestETag"
)

// swiftlint:disable:next force_unwrapping
func testPatcher_Init() {
XCTAssertEqual(patcher.id, "TestUserId")
XCTAssertEqual(patcher.updated, .distantFuture)
Expand All @@ -63,6 +62,7 @@ class PubNubUserPatcherTests: XCTestCase {
XCTAssertEqual(patcher.type, .some("TestType"))
XCTAssertEqual(patcher.status, .some("TestStatus"))
XCTAssertEqual(patcher.externalId, .some("TestExternalId"))
// swiftlint:disable:next force_unwrapping
XCTAssertEqual(patcher.profileURL, .some(URL(string: "http://example.com")!))
XCTAssertEqual(patcher.email, .some("TestEmail"))
XCTAssertEqual(
Expand Down
1 change: 1 addition & 0 deletions PubNubUser/Tests/UserTestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ extension EndpointResponse where Value == Data {
init(data: Data?) {
self.init(
router: MockRouter(),
// swiftlint:disable:next force_unwrapping
request: .init(url: URL(string: "example.com")!),
response: .init(),
payload: data ?? Data()
Expand Down
1 change: 1 addition & 0 deletions Sources/PubNub/EventEngine/Subscribe/Subscribe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extension Subscribe {
}

struct UnsubscribedState: SubscribeState {
// swiftlint:disable:next force_unwrapping
let cursor: SubscribeCursor = .init(timetoken: 0)!
let input: SubscribeInput = .init()
let connectionStatus = ConnectionStatus.disconnected
Expand Down
2 changes: 1 addition & 1 deletion Sources/PubNub/Networking/HTTPFileTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class HTTPFileTask: Hashable {

func updateProgress(bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
// Progress is handled automatically on iOS 11+
if #available(iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0, *) { } else {
if #unavailable(iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0) {
progress.completedUnitCount = totalBytesWritten
}

Expand Down

0 comments on commit 41c5faf

Please sign in to comment.