Skip to content

Use MuxUpload id instead if the input URL when looking up or writing … #31

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

andrewjl-mux
Copy link
Contributor

…state in the SDK

@andrewjl-mux andrewjl-mux requested a review from daytime-em June 9, 2023 19:58
@andrewjl-mux andrewjl-mux force-pushed the ajlb/read-and-write-upload-state-using-id branch from a2c0604 to ec6ea05 Compare June 9, 2023 20:00
@andrewjl-mux andrewjl-mux changed the base branch from ajlb/use-uuid-string-muxupload-internal-identifier to releases/v0.4.0 June 9, 2023 20:00
Copy link
Collaborator

@daytime-em daytime-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the changes!

@andrewjl-mux
Copy link
Contributor Author

@daytime-em will be adding a few more changes here

Changed the MuxUpload id to be a computed property to avoid storing it in 2 places unnecessarily. In Swift computed properties are not settable despite being marked var.

// Shouldn't throw (but not specifically part of the test)
try! persistence.write(entry: e1, forFileAt: makeDummyFileURL(basename: "e1"))
try! persistence.write(entry: e2, forFileAt: makeDummyFileURL(basename: "e2"))
XCTAssertNoThrow(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XCTAssertNoThrow is effectively the same as try! (the test will fail and throw either way if this expression throws). One bonus behind asserting here is it does also allow us to pass a string that gets printed when a specific assertion fails.

let readItem1 = try XCTUnwrap(
persistence.readEntry(uploadID: e2.uploadInfo.id)
)
let readItem2 = try XCTUnwrap(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converts what is otherwise a crash into a failing test. More here: https://useyourloaf.com/blog/xctunwrap-optionals-in-your-tests/

e1.uploadInfo.videoFile,
"read() should return the right item"
)
XCTAssertEqual(
// remember, they're swapped
readItem1!.uploadInfo.videoFile,
readItem1.uploadInfo.videoFile,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ! can now be removed due to the XCTUnwrap above.

@andrewjl-mux andrewjl-mux marked this pull request as ready for review June 12, 2023 21:21
@andrewjl-mux andrewjl-mux requested a review from a team as a code owner June 12, 2023 21:21
Copy link
Collaborator

@daytime-em daytime-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andrewjl-mux andrewjl-mux merged commit ff72db1 into releases/v0.4.0 Jun 13, 2023
@andrewjl-mux andrewjl-mux deleted the ajlb/read-and-write-upload-state-using-id branch June 13, 2023 00:40
@andrewjl-mux andrewjl-mux restored the ajlb/read-and-write-upload-state-using-id branch June 13, 2023 00:43
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants