-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix simulator putfile posix error #16386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+138
−4
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2bbc565
Fix Storage putFile POSIX error 40 on iOS Simulator
paulb777 8c7581e
style
paulb777 65e6f3e
changelog
paulb777 4cec04c
copyright
paulb777 c7e7a4c
review
paulb777 a423ac0
More tests
paulb777 c235833
review
paulb777 7045ff3
more review
paulb777 6a0f6aa
review
paulb777 a4bae12
review
paulb777 e093213
Test updates for previous library change
paulb777 7d3a867
style
paulb777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
FirebaseStorage/Tests/Integration/StoragePOSIXErrorTest.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| @testable import FirebaseStorage | ||
| import Foundation | ||
| #if COCOAPODS | ||
| import GTMSessionFetcher | ||
| #else | ||
| import GTMSessionFetcherCore | ||
| #endif | ||
| import XCTest | ||
|
|
||
| @available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 6.0, *) | ||
| class StoragePOSIXErrorTest: StorageIntegrationCommon { | ||
| func testPutFileWithPOSIXError40() async throws { | ||
| let ref = storage.reference(withPath: "ios/public/testPOSIX40") | ||
|
|
||
| let data = try XCTUnwrap("Hello".data(using: .utf8)) | ||
| let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory()) | ||
| let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt") | ||
| try data.write(to: fileURL, options: .atomicWrite) | ||
|
paulb777 marked this conversation as resolved.
|
||
| addTeardownBlock { | ||
| try? FileManager.default.removeItem(at: fileURL) | ||
| } | ||
|
|
||
| let metadata = try await ref.putFileAsync(from: fileURL) | ||
| XCTAssertEqual(metadata.size, Int64(data.count)) | ||
| } | ||
| } | ||
|
paulb777 marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| @testable import FirebaseStorage | ||
| import Foundation | ||
| #if COCOAPODS | ||
| import GTMSessionFetcher | ||
| #else | ||
| import GTMSessionFetcherCore | ||
| #endif | ||
| import XCTest | ||
|
|
||
| class StoragePutFileTests: StorageTestHelpers { | ||
| func testPutFileWithPOSIXError40UpdatesExistingFetcherService() async throws { | ||
| // Initialize storage *before* setting the testBlock to verify that | ||
| // `StorageFetcherService.updateTestBlock` correctly updates pre-existing instances. | ||
| let storageInstance = storage() | ||
| let ref = storageInstance.reference(withPath: "ios/public/testPOSIX40") | ||
|
|
||
| let testBlock: GTMSessionFetcherTestBlock = { fetcher, response in | ||
| let error = NSError(domain: NSPOSIXErrorDomain, code: 40, userInfo: nil) | ||
| response(nil, nil, error) | ||
| } | ||
| await StorageFetcherService.shared.updateTestBlock(testBlock) | ||
| addTeardownBlock { | ||
| await StorageFetcherService.shared.updateTestBlock(nil) | ||
| } | ||
|
|
||
| let data = try XCTUnwrap("Hello".data(using: .utf8)) | ||
| let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory()) | ||
| let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt") | ||
| try data.write(to: fileURL, options: .atomicWrite) | ||
| addTeardownBlock { | ||
| try? FileManager.default.removeItem(at: fileURL) | ||
| } | ||
|
|
||
| do { | ||
| _ = try await ref.putFileAsync(from: fileURL) | ||
| XCTFail("Unexpected success") | ||
| } catch let error as NSError { | ||
| XCTAssertEqual(error.domain, StorageErrorDomain) | ||
| XCTAssertEqual(error.code, StorageErrorCode.unknown.rawValue) | ||
| let message = error.localizedDescription | ||
| XCTAssertTrue( | ||
| message.contains("POSIX errno 40 (The operation couldn’t be completed. Message too long)"), | ||
| "Error message should contain 'POSIX errno 40 (The operation couldn’t be completed. Message too long)', but got \(message)" | ||
| ) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.