Skip to content

Commit cbedd5f

Browse files
committed
Failing -> Unimplemented (#1168)
1 parent 0080902 commit cbedd5f

File tree

22 files changed

+110
-107
lines changed

22 files changed

+110
-107
lines changed

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-SystemEnvironment.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,11 @@ struct SystemEnvironment<Environment> {
205205
import XCTestDynamicOverlay
206206

207207
extension SystemEnvironment {
208-
static func failing(
209-
date: @escaping () -> Date = {
210-
XCTFail("date dependency is unimplemented.")
211-
return Date()
212-
},
208+
static func unimplemented(
209+
date: @escaping () -> Date = XCTUnimplemented("\(Self.self).date", placeholder: Date()),
213210
environment: Environment,
214-
mainQueue: DateScheduler = FailingScheduler(),
215-
uuid: @escaping () -> UUID = {
216-
XCTFail("UUID dependency is unimplemented.")
217-
return UUID()
218-
}
211+
mainQueue: DateScheduler = UnimplementedScheduler(),
212+
uuid: @escaping () -> UUID = XCTUnimplemented("\(Self.self).uuid", placeholder: UUID())
219213
) -> Self {
220214
Self(
221215
date: date,

Examples/CaseStudies/SwiftUICaseStudies/FactClient.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ extension FactClient {
2828

2929
#if DEBUG
3030
extension FactClient {
31-
// This is the "failing" fact dependency that is useful to plug into tests that you want
31+
// This is the "unimplemented" fact dependency that is useful to plug into tests that you want
3232
// to prove do not need the dependency.
33-
static let failing = Self(
34-
fetch: { _ in .failing("\(Self.self).fact is unimplemented.") }
33+
static let unimplemented = Self(
34+
fetch: { _ in .unimplemented("\(Self.self).fact") }
3535
)
3636
}
3737
#endif

Examples/CaseStudies/SwiftUICaseStudiesTests/02-Effects-BasicsTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class EffectsBasicsTests: XCTestCase {
1010
initialState: EffectsBasicsState(),
1111
reducer: effectsBasicsReducer,
1212
environment: EffectsBasicsEnvironment(
13-
fact: .failing,
13+
fact: .unimplemented,
1414
mainQueue: ImmediateScheduler()
1515
)
1616
)
@@ -27,7 +27,7 @@ class EffectsBasicsTests: XCTestCase {
2727
let store = TestStore(
2828
initialState: EffectsBasicsState(),
2929
reducer: effectsBasicsReducer,
30-
environment: .failing
30+
environment: .unimplemented
3131
)
3232

3333
store.environment.fact.fetch = { Effect(value: "\($0) is a good number Brent") }
@@ -49,7 +49,7 @@ class EffectsBasicsTests: XCTestCase {
4949
let store = TestStore(
5050
initialState: EffectsBasicsState(),
5151
reducer: effectsBasicsReducer,
52-
environment: .failing
52+
environment: .unimplemented
5353
)
5454

5555
store.environment.fact.fetch = { _ in Effect(error: FactClient.Error()) }
@@ -68,8 +68,8 @@ class EffectsBasicsTests: XCTestCase {
6868
}
6969

7070
extension EffectsBasicsEnvironment {
71-
static let failing = Self(
72-
fact: .failing,
73-
mainQueue: .failing
71+
static let unimplemented = Self(
72+
fact: .unimplemented,
73+
mainQueue: .unimplemented
7474
)
7575
}

Examples/CaseStudies/SwiftUICaseStudiesTests/02-Effects-WebSocketTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class WebSocketTests: XCTestCase {
99
let socketSubject = Signal<WebSocketClient.Action, Never>.pipe()
1010
let receiveSubject = Signal<WebSocketClient.Message, NSError>.pipe()
1111

12-
var webSocket = WebSocketClient.failing
12+
var webSocket = WebSocketClient.unimplemented
1313
webSocket.open = { _, _, _ in socketSubject.output.producer }
1414
webSocket.receive = { _ in receiveSubject.output.producer }
1515
webSocket.send = { _, _ in Effect(value: nil) }
@@ -58,7 +58,7 @@ class WebSocketTests: XCTestCase {
5858
let socketSubject = Signal<WebSocketClient.Action, Never>.pipe()
5959
let receiveSubject = Signal<WebSocketClient.Message, NSError>.pipe()
6060

61-
var webSocket = WebSocketClient.failing
61+
var webSocket = WebSocketClient.unimplemented
6262
webSocket.open = { _, _, _ in socketSubject.output.producer }
6363
webSocket.receive = { _ in receiveSubject.output.producer }
6464
webSocket.send = { _, _ in Effect(value: NSError(domain: "", code: 1)) }
@@ -103,7 +103,7 @@ class WebSocketTests: XCTestCase {
103103
let socketSubject = Signal<WebSocketClient.Action, Never>.pipe()
104104
let pingSubject = Signal<NSError?, Never>.pipe()
105105

106-
var webSocket = WebSocketClient.failing
106+
var webSocket = WebSocketClient.unimplemented
107107
webSocket.open = { _, _, _ in socketSubject.output.producer }
108108
webSocket.receive = { _ in .none }
109109
webSocket.sendPing = { _ in pingSubject.output.producer }
@@ -141,7 +141,7 @@ class WebSocketTests: XCTestCase {
141141
func testWebSocketConnectError() {
142142
let socketSubject = Signal<WebSocketClient.Action, Never>.pipe()
143143

144-
var webSocket = WebSocketClient.failing
144+
var webSocket = WebSocketClient.unimplemented
145145
webSocket.cancel = { _, _, _ in .fireAndForget { socketSubject.input.sendCompleted() } }
146146
webSocket.open = { _, _, _ in socketSubject.output.producer }
147147
webSocket.receive = { _ in .none }
@@ -168,11 +168,11 @@ class WebSocketTests: XCTestCase {
168168
}
169169

170170
extension WebSocketClient {
171-
static let failing = Self(
172-
cancel: { _, _, _ in .failing("WebSocketClient.cancel") },
173-
open: { _, _, _ in .failing("WebSocketClient.open") },
174-
receive: { _ in .failing("WebSocketClient.receive") },
175-
send: { _, _ in .failing("WebSocketClient.send") },
176-
sendPing: { _ in .failing("WebSocketClient.sendPing") }
171+
static let unimplemented = Self(
172+
cancel: { _, _, _ in .unimplemented("\(Self.self).cancel") },
173+
open: { _, _, _ in .unimplemented("\(Self.self).open") },
174+
receive: { _ in .unimplemented("\(Self.self).receive") },
175+
send: { _, _ in .unimplemented("\(Self.self).send") },
176+
sendPing: { _ in .unimplemented("\(Self.self).sendPing") }
177177
)
178178
}

Examples/CaseStudies/SwiftUICaseStudiesTests/04-HigherOrderReducers-ReusableOfflineDownloadsTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
1818
let scheduler = TestScheduler()
1919

2020
func testDownloadFlow() {
21-
var downloadClient = DownloadClient.failing
21+
var downloadClient = DownloadClient.unimplemented
2222
downloadClient.download = { _ in self.downloadSubject.output.producer }
2323

2424
let store = TestStore(
@@ -54,7 +54,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
5454
}
5555

5656
func testDownloadThrottling() {
57-
var downloadClient = DownloadClient.failing
57+
var downloadClient = DownloadClient.unimplemented
5858
downloadClient.download = { _ in self.downloadSubject.output.producer }
5959

6060
let store = TestStore(
@@ -94,7 +94,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
9494
}
9595

9696
func testCancelDownloadFlow() {
97-
var downloadClient = DownloadClient.failing
97+
var downloadClient = DownloadClient.unimplemented
9898
downloadClient.download = { _ in self.downloadSubject.output.producer }
9999

100100
let store = TestStore(
@@ -131,7 +131,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
131131
}
132132

133133
func testDownloadFinishesWhileTryingToCancel() {
134-
var downloadClient = DownloadClient.failing
134+
var downloadClient = DownloadClient.unimplemented
135135
downloadClient.download = { _ in self.downloadSubject.output.producer }
136136

137137
let store = TestStore(
@@ -170,7 +170,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
170170
}
171171

172172
func testDeleteDownloadFlow() {
173-
var downloadClient = DownloadClient.failing
173+
var downloadClient = DownloadClient.unimplemented
174174
downloadClient.download = { _ in self.downloadSubject.output.producer }
175175

176176
let store = TestStore(
@@ -202,7 +202,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
202202
}
203203

204204
extension DownloadClient {
205-
static let failing = Self(
206-
download: { _ in .failing("DownloadClient.download") }
205+
static let unimplemented = Self(
206+
download: { _ in .unimplemented("\(Self.self).download") }
207207
)
208208
}

Examples/Search/Search/WeatherClient.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ extension WeatherClient {
8181
// MARK: - Mock API implementations
8282

8383
extension WeatherClient {
84-
static let failing = Self(
85-
forecast: { _ in .failing("\(Self.self).forecast") },
86-
search: { _ in .failing("\(Self.self).search") }
84+
static let unimplemented = Self(
85+
forecast: { _ in .unimplemented("\(Self.self).forecast") },
86+
search: { _ in .unimplemented("\(Self.self).search") }
8787
)
8888
}
8989

Examples/Search/SearchTests/SearchTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SearchTests: XCTestCase {
1212
initialState: SearchState(),
1313
reducer: searchReducer,
1414
environment: SearchEnvironment(
15-
weatherClient: .failing,
15+
weatherClient: .unimplemented,
1616
mainQueue: self.scheduler
1717
)
1818
)
@@ -36,7 +36,7 @@ class SearchTests: XCTestCase {
3636
initialState: SearchState(),
3737
reducer: searchReducer,
3838
environment: SearchEnvironment(
39-
weatherClient: .failing,
39+
weatherClient: .unimplemented,
4040
mainQueue: self.scheduler
4141
)
4242
)
@@ -50,7 +50,7 @@ class SearchTests: XCTestCase {
5050
}
5151

5252
func testClearQueryCancelsInFlightSearchRequest() {
53-
var weatherClient = WeatherClient.failing
53+
var weatherClient = WeatherClient.unimplemented
5454
weatherClient.search = { _ in Effect(value: .mock) }
5555

5656
let store = TestStore(
@@ -84,7 +84,7 @@ class SearchTests: XCTestCase {
8484
var results = Search.mock.results
8585
results.append(specialResult)
8686

87-
var weatherClient = WeatherClient.failing
87+
var weatherClient = WeatherClient.unimplemented
8888
weatherClient.forecast = { _ in Effect(value: .mock) }
8989

9090
let store = TestStore(
@@ -143,7 +143,7 @@ class SearchTests: XCTestCase {
143143
var results = Search.mock.results
144144
results.append(specialResult)
145145

146-
var weatherClient = WeatherClient.failing
146+
var weatherClient = WeatherClient.unimplemented
147147
weatherClient.forecast = { _ in Effect(value: .mock) }
148148

149149
let store = TestStore(
@@ -194,7 +194,7 @@ class SearchTests: XCTestCase {
194194
}
195195

196196
func testTapOnLocationFailure() {
197-
var weatherClient = WeatherClient.failing
197+
var weatherClient = WeatherClient.unimplemented
198198
weatherClient.forecast = { _ in Effect(error: WeatherClient.Failure()) }
199199

200200
let results = Search.mock.results

Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Failing.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import Speech
44

55
#if DEBUG
66
extension SpeechClient {
7-
static let failing = Self(
8-
finishTask: { .failing("SpeechClient.finishTask") },
9-
recognitionTask: { _ in .failing("SpeechClient.recognitionTask") },
10-
requestAuthorization: { .failing("SpeechClient.requestAuthorization") }
7+
static let unimplemented = Self(
8+
finishTask: { .unimplemented("\(Self.self).finishTask") },
9+
recognitionTask: { _ in .unimplemented("\(Self.self).recognitionTask") },
10+
requestAuthorization: { .unimplemented("\(Self.self).requestAuthorization") }
1111
)
1212
}
1313
#endif

Examples/SpeechRecognition/SpeechRecognitionTests/SpeechRecognitionTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SpeechRecognitionTests: XCTestCase {
88
let recognitionTaskSubject = Signal<SpeechClient.Action, SpeechClient.Error>.pipe()
99

1010
func testDenyAuthorization() {
11-
var speechClient = SpeechClient.failing
11+
var speechClient = SpeechClient.unimplemented
1212
speechClient.requestAuthorization = { Effect(value: .denied) }
1313

1414
let store = TestStore(
@@ -37,7 +37,7 @@ class SpeechRecognitionTests: XCTestCase {
3737
}
3838

3939
func testRestrictedAuthorization() {
40-
var speechClient = SpeechClient.failing
40+
var speechClient = SpeechClient.unimplemented
4141
speechClient.requestAuthorization = { Effect(value: .restricted) }
4242

4343
let store = TestStore(
@@ -60,7 +60,7 @@ class SpeechRecognitionTests: XCTestCase {
6060
}
6161

6262
func testAllowAndRecord() {
63-
var speechClient = SpeechClient.failing
63+
var speechClient = SpeechClient.unimplemented
6464
speechClient.finishTask = {
6565
.fireAndForget { self.recognitionTaskSubject.input.sendCompleted() }
6666
}
@@ -108,7 +108,7 @@ class SpeechRecognitionTests: XCTestCase {
108108
}
109109

110110
func testAudioSessionFailure() {
111-
var speechClient = SpeechClient.failing
111+
var speechClient = SpeechClient.unimplemented
112112
speechClient.recognitionTask = { _ in self.recognitionTaskSubject.output.producer }
113113
speechClient.requestAuthorization = { Effect(value: .authorized) }
114114

@@ -138,7 +138,7 @@ class SpeechRecognitionTests: XCTestCase {
138138
}
139139

140140
func testAudioEngineFailure() {
141-
var speechClient = SpeechClient.failing
141+
var speechClient = SpeechClient.unimplemented
142142
speechClient.recognitionTask = { _ in self.recognitionTaskSubject.output.producer }
143143
speechClient.requestAuthorization = { Effect(value: .authorized) }
144144

Examples/TicTacToe/tic-tac-toe/Sources/AuthenticationClient/AuthenticationClient.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public struct AuthenticationClient {
7272

7373
#if DEBUG
7474
extension AuthenticationClient {
75-
public static let failing = Self(
76-
login: { _ in .failing("AuthenticationClient.login") },
77-
twoFactor: { _ in .failing("AuthenticationClient.twoFactor") }
75+
public static let unimplemented = Self(
76+
login: { _ in .unimplemented("\(Self.self).login") },
77+
twoFactor: { _ in .unimplemented("\(Self.self).twoFactor") }
7878
)
7979
}
8080
#endif

0 commit comments

Comments
 (0)