Skip to content

Commit 3328a8c

Browse files
committed
Polling Confirmations: Rename to actually use the confirmation name
Follow more english-sentence-like guidance for function naming Simplify the polling confirmation API down to just 2 public functions, 1 enum, and 1 error type. Always throw an error when polling fails, get rid of the separate issue recording.
1 parent 5b7d798 commit 3328a8c

File tree

4 files changed

+494
-577
lines changed

4 files changed

+494
-577
lines changed

Sources/Testing/Issues/Issue.swift

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ public struct Issue: Sendable {
3838
/// confirmed too few or too many times.
3939
indirect case confirmationMiscounted(actual: Int, expected: any RangeExpression & Sendable)
4040

41+
/// An issue due to a polling confirmation having failed.
42+
///
43+
/// This issue can occur when calling ``confirmation(_:until:within:pollingEvery:isolation:sourceLocation:_:)-455gr``
44+
/// or
45+
/// ``confirmation(_:until:within:pollingEvery:isolation:sourceLocation:_:)-5tnlk``
46+
/// whenever the polling fails, as described in ``PollingStopCondition``.
4147
@_spi(Experimental)
42-
case confirmationPollingFailed
48+
case pollingConfirmationFailed
4349

4450
/// An issue due to an `Error` being thrown by a test function and caught by
4551
/// the testing library.
@@ -289,8 +295,8 @@ extension Issue.Kind: CustomStringConvertible {
289295
}
290296
}
291297
return "Confirmation was confirmed \(actual.counting("time")), but expected to be confirmed \(String(describingForTest: expected)) time(s)"
292-
case .confirmationPollingFailed:
293-
return "Confirmation polling failed"
298+
case .pollingConfirmationFailed:
299+
return "Polling confirmation failed"
294300
case let .errorCaught(error):
295301
return "Caught error: \(error)"
296302
case let .timeLimitExceeded(timeLimitComponents: timeLimitComponents):
@@ -427,6 +433,15 @@ extension Issue.Kind {
427433
/// too few or too many times.
428434
indirect case confirmationMiscounted(actual: Int, expected: Int)
429435

436+
/// An issue due to a polling confirmation having failed.
437+
///
438+
/// This issue can occur when calling ``confirmation(_:until:within:pollingEvery:isolation:sourceLocation:_:)-455gr``
439+
/// or
440+
/// ``confirmation(_:until:within:pollingEvery:isolation:sourceLocation:_:)-5tnlk``
441+
/// whenever the polling fails, as described in ``PollingStopCondition``.
442+
@_spi(Experimental)
443+
case pollingConfirmationFailed
444+
430445
/// An issue due to an `Error` being thrown by a test function and caught by
431446
/// the testing library.
432447
///
@@ -470,8 +485,8 @@ extension Issue.Kind {
470485
.expectationFailed(Expectation.Snapshot(snapshotting: expectation))
471486
case .confirmationMiscounted:
472487
.unconditional
473-
case .confirmationPollingFailed:
474-
.unconditional
488+
case .pollingConfirmationFailed:
489+
.pollingConfirmationFailed
475490
case let .errorCaught(error), let .valueAttachmentFailed(error):
476491
.errorCaught(ErrorSnapshot(snapshotting: error))
477492
case let .timeLimitExceeded(timeLimitComponents: timeLimitComponents):
@@ -490,6 +505,7 @@ extension Issue.Kind {
490505
case unconditional
491506
case expectationFailed
492507
case confirmationMiscounted
508+
case pollingConfirmationFailed
493509
case errorCaught
494510
case timeLimitExceeded
495511
case knownIssueNotRecorded
@@ -562,6 +578,8 @@ extension Issue.Kind {
562578
forKey: .confirmationMiscounted)
563579
try confirmationMiscountedContainer.encode(actual, forKey: .actual)
564580
try confirmationMiscountedContainer.encode(expected, forKey: .expected)
581+
case .pollingConfirmationFailed:
582+
try container.encode(true, forKey: .pollingConfirmationFailed)
565583
case let .errorCaught(error):
566584
var errorCaughtContainer = container.nestedContainer(keyedBy: _CodingKeys._ErrorCaughtKeys.self, forKey: .errorCaught)
567585
try errorCaughtContainer.encode(error, forKey: .error)
@@ -617,6 +635,8 @@ extension Issue.Kind.Snapshot: CustomStringConvertible {
617635
}
618636
case let .confirmationMiscounted(actual: actual, expected: expected):
619637
"Confirmation was confirmed \(actual.counting("time")), but expected to be confirmed \(expected.counting("time"))"
638+
case .pollingConfirmationFailed:
639+
"Polling confirmation failed"
620640
case let .errorCaught(error):
621641
"Caught error: \(error)"
622642
case let .timeLimitExceeded(timeLimitComponents: timeLimitComponents):

0 commit comments

Comments
 (0)