-
Notifications
You must be signed in to change notification settings - Fork 191
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
Adds more unit tests for WCPairing #437
Conversation
Btw, while on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test needs a fix (update less than expiry)
func testUpdateExpiry_WhenNewExpiryDateIsLessThanExpiryDate_ShouldThrowInvalidUpdateExpiryValue() { | ||
let expiryDate = referenceDate.advanced(by: 10 * .minute) | ||
var pairing = WCPairing(topic: "", relay: .stub(), peerMetadata: .stub(), expiryDate: expiryDate) | ||
XCTAssertThrowsError(try pairing.updateExpiry(40 * .day)) { error in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expire date you set is 10 minutes into the future, the update value should be less than this, like the test says, but you're testing with a 40-day date (greater than max, like the test above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops! 😅
pairing.activate() | ||
XCTAssertThrowsError(try pairing.updateExpiry(10 * .minute)) { error in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activate()
makes a call to updateExpiry()
internally (which sets a 30-day expiry).
Is there a reason to call activate before a throwing update? Does it make a difference for this test to invert the order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to check the error inside the activate()
function, but if I understood it right, the error dies inside activate()
. I changed the test, now checking for the expiryDate
update. If an error occurs, it shouldn't be updated.
lgtm, more tests is always better 👍 |
@flypaper0 updated! Do these new names fit better? |
While working on this I noticed that the
activate
function sets the status totrue
even ifupdateExpiry
throws an error. Is that the expected behavior? Maybeactivate
should only change theactive
var?