mirror of
https://github.com/Lakr233/vphone-cli.git
synced 2026-10-01 23:54:35 +08:00
Expect the restore errors the code actually reports
`Reword user-facing errors...` (090df08) and `Rewrite error messages and labels...` (c27ea64) replaced the wording the Python bridge used with text that says what failed and what to do next. Three tests still asserted the old strings, so VPhoneRestoreTests has been failing ever since on five expectations that describe a message nothing produces. Assert the current messages and rename the tests, which no longer claim to pin Python's wording. The type's doc comment made the same stale claim; it now says the cases came from the bridge and the messages did not. VPhoneRestoreTests: 67 tests in 6 suites pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+4
-3
@@ -8,9 +8,10 @@ import Foundation
|
||||
/// type by that name and `vphone-cli` imports both, so sharing it would make
|
||||
/// every unqualified use ambiguous.
|
||||
///
|
||||
/// The messages of the first five cases are word for word the ones
|
||||
/// `scripts/pymobiledevice3_bridge.py` printed, because scripts and people
|
||||
/// have been reading them for a while.
|
||||
/// The first five cases are the ones `scripts/pymobiledevice3_bridge.py` used
|
||||
/// to raise, and the notes below record what it reported for each. The
|
||||
/// messages themselves are no longer its wording: they were rewritten to say
|
||||
/// what failed and what to do next.
|
||||
public enum VPhoneRestoreBackendError: Error, Equatable {
|
||||
// MARK: ECID
|
||||
|
||||
|
||||
+9
-5
@@ -124,18 +124,22 @@ struct RestoreEventTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func `the timeout message is the pythons word for word`() {
|
||||
@Test func `the timeout message names the mode and what to do next`() {
|
||||
let error = VPhoneRestoreBackendError.recoveryProbeTimedOut(mode: "dfu/recovery")
|
||||
#expect("\(error)" == "Timed out waiting for dfu/recovery endpoint")
|
||||
#expect("\(error)"
|
||||
== "The device did not enter dfu/recovery mode in time. Check the connection, then try again.")
|
||||
}
|
||||
|
||||
// MARK: - Error messages
|
||||
|
||||
@Test func `the restore tree messages are the pythons word for word`() {
|
||||
@Test func `the restore tree messages say which folder is wrong`() {
|
||||
// These once repeated Python's wording verbatim. They were rewritten to
|
||||
// say what to do next; the one that can name a path still names it.
|
||||
let none = VPhoneRestoreBackendError.noRestoreDirectory(URL(fileURLWithPath: "/tmp/vm"))
|
||||
#expect("\(none)" == "No iPhone*_Restore directory found in /tmp/vm")
|
||||
#expect("\(none)"
|
||||
== "No restore folder was found in /tmp/vm. Prepare the firmware, then try again.")
|
||||
let several = VPhoneRestoreBackendError.multipleRestoreDirectories(["a", "b"])
|
||||
#expect("\(several)"
|
||||
== "Multiple iPhone*_Restore directories found; keep only one active restore tree")
|
||||
== "More than one restore folder was found. Keep only one, then try again.")
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -73,9 +73,14 @@ struct RestoreIdentityTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func `invalid ECID carries the python message`() {
|
||||
#expect("\(VPhoneRestoreBackendError.ecidEmpty)" == "ECID is empty")
|
||||
#expect("\(VPhoneRestoreBackendError.ecidInvalid("zz"))" == "Invalid ECID: zz")
|
||||
@Test func `an invalid ECID says what to enter instead`() {
|
||||
// The bridge once reported Python's wording; the messages were rewritten
|
||||
// to say what failed and what to do next. Both still name the rejected
|
||||
// value and the format that would be accepted.
|
||||
#expect("\(VPhoneRestoreBackendError.ecidEmpty)"
|
||||
== "The ECID is empty. Enter up to 16 hexadecimal digits.")
|
||||
#expect("\(VPhoneRestoreBackendError.ecidInvalid("zz"))"
|
||||
== "zz is not a valid ECID. Enter up to 16 hexadecimal digits.")
|
||||
}
|
||||
|
||||
// MARK: - UDID
|
||||
|
||||
Reference in New Issue
Block a user