Skip to content

Commit 63e0b33

Browse files
committed
Re-add AlamofireTests.
1 parent 6ef98f0 commit 63e0b33

File tree

4 files changed

+22
-45
lines changed

4 files changed

+22
-45
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
url = https://github.com/ReactKit/SwiftState.git
44
[submodule "Vendor/Alamofire"]
55
path = Vendor/Alamofire
6-
url = https://github.com/inamiy/Alamofire.git
6+
url = https://github.com/Alamofire/Alamofire.git
77
[submodule "Vendor/Async"]
88
path = Vendor/Async
99
url = https://github.com/duemunk/Async.git

SwiftTask.xcodeproj/project.pbxproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
1F0E284019C1DEA0005EF467 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0E282319C1DEA0005EF467 /* Async.swift */; };
1111
1F20250219ADA8FD00DE0495 /* BasicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F20250119ADA8FD00DE0495 /* BasicTests.swift */; };
1212
1F24C72B19D0688800C2FDC7 /* SwiftTask.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48CD5A0C19AEE3570042B9F1 /* SwiftTask.framework */; };
13+
1F2C0C1C1A32A15300CFBB47 /* AlamofireTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5FA35619A374E600975FB9 /* AlamofireTests.swift */; };
14+
1F2C0C1D1A32A15300CFBB47 /* AlamofireTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5FA35619A374E600975FB9 /* AlamofireTests.swift */; };
15+
1F2C0C1E1A32A19300CFBB47 /* Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FA4631719A8D70A00DD8729 /* Alamofire.swift */; };
16+
1F2C0C1F1A32A19300CFBB47 /* Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FA4631719A8D70A00DD8729 /* Alamofire.swift */; };
1317
1F46DEDA199EDF1000F97868 /* SwiftTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F46DED9199EDF1000F97868 /* SwiftTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
1418
1F46DEFB199EDF8100F97868 /* SwiftTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F46DEFA199EDF8100F97868 /* SwiftTask.swift */; };
1519
1F46DEFD199EE2C200F97868 /* _TestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F46DEFC199EE2C200F97868 /* _TestCase.swift */; };
@@ -223,7 +227,7 @@
223227
isa = PBXGroup;
224228
children = (
225229
1FA4634319A8D70A00DD8729 /* SwiftState.framework */,
226-
1FA4634519A8D70A00DD8729 /* SwiftStateTests.xctest */,
230+
1FA4634519A8D70A00DD8729 /* SwiftState-OSXTests.xctest */,
227231
4872D5C819B423D600F326B5 /* SwiftState.framework */,
228232
4822F0C019D00A7800F5F572 /* SwiftStateTests-iOS.xctest */,
229233
);
@@ -380,7 +384,7 @@
380384
remoteRef = 1FA4634219A8D70A00DD8729 /* PBXContainerItemProxy */;
381385
sourceTree = BUILT_PRODUCTS_DIR;
382386
};
383-
1FA4634519A8D70A00DD8729 /* SwiftStateTests.xctest */ = {
387+
1FA4634519A8D70A00DD8729 /* SwiftState-OSXTests.xctest */ = {
384388
isa = PBXReferenceProxy;
385389
fileType = wrapper.cfbundle;
386390
path = "SwiftState-OSXTests.xctest";
@@ -449,7 +453,9 @@
449453
files = (
450454
1F20250219ADA8FD00DE0495 /* BasicTests.swift in Sources */,
451455
1F0E284019C1DEA0005EF467 /* Async.swift in Sources */,
456+
1F2C0C1E1A32A19300CFBB47 /* Alamofire.swift in Sources */,
452457
1F6A8CA319A4E4F200369A5D /* SwiftTaskTests.swift in Sources */,
458+
1F2C0C1C1A32A15300CFBB47 /* AlamofireTests.swift in Sources */,
453459
485C31F11A1D619A00040DA3 /* TypeInferenceTests.swift in Sources */,
454460
48511C5B19C17563002FE03C /* RetainCycleTests.swift in Sources */,
455461
1F46DEFD199EE2C200F97868 /* _TestCase.swift in Sources */,
@@ -462,7 +468,9 @@
462468
files = (
463469
4822F0DE19D00B2300F5F572 /* SwiftTaskTests.swift in Sources */,
464470
4822F0DD19D00B2300F5F572 /* BasicTests.swift in Sources */,
471+
1F2C0C1F1A32A19300CFBB47 /* Alamofire.swift in Sources */,
465472
4822F0E319D00B3100F5F572 /* Async.swift in Sources */,
473+
1F2C0C1D1A32A15300CFBB47 /* AlamofireTests.swift in Sources */,
466474
485C31F21A1D619A00040DA3 /* TypeInferenceTests.swift in Sources */,
467475
4822F0DC19D00B2300F5F572 /* _TestCase.swift in Sources */,
468476
4822F0E019D00B2300F5F572 /* RetainCycleTests.swift in Sources */,

SwiftTaskTests/AlamofireTests.swift

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import SwiftTask
10+
//import Alamofire // comment-out: include source code for OSX test as well
1011
import XCTest
1112

1213
class AlamofireTests: _TestCase
@@ -21,10 +22,6 @@ class AlamofireTests: _TestCase
2122

2223
request(.GET, "http://httpbin.org/get", parameters: ["foo": "bar"])
2324
.response { (request, response, data, error) in
24-
25-
println(request)
26-
println(response)
27-
println(error)
2825

2926
if let error = error {
3027
reject(error)
@@ -39,9 +36,8 @@ class AlamofireTests: _TestCase
3936

4037
}
4138

42-
task.then { (value: String) -> Void in
39+
task.success { (value: String) -> Void in
4340
XCTAssertEqual(value, "OK")
44-
4541
expect.fulfill()
4642
}
4743

@@ -59,10 +55,6 @@ class AlamofireTests: _TestCase
5955
request(.GET, dummyURLString, parameters: ["foo": "bar"])
6056
.response { (request, response, data, error) in
6157

62-
println(request)
63-
println(response)
64-
println(error)
65-
6658
if let error = error {
6759
reject(error) // pass non-nil error
6860
return
@@ -74,16 +66,13 @@ class AlamofireTests: _TestCase
7466

7567
}
7668

77-
task.then { (value: String?) -> Void in
69+
task.success { (value: String?) -> Void in
7870

7971
XCTFail("Should never reach here.")
8072

8173
}.failure { (error: NSError?, isCancelled: Bool) -> Void in
8274

83-
// println(error)
84-
8575
XCTAssertTrue(error != nil, "Should receive non-nil error.")
86-
8776
expect.fulfill()
8877

8978
}
@@ -106,10 +95,6 @@ class AlamofireTests: _TestCase
10695

10796
}.response { (request, response, data, error) in
10897

109-
println(request)
110-
println(response)
111-
println(error)
112-
11398
if let error = error {
11499
reject(error)
115100
return
@@ -124,16 +109,14 @@ class AlamofireTests: _TestCase
124109
}
125110

126111
// set progress & then
127-
task.progress { progress in
112+
task.progress { _, progress in
128113

129114
println("bytesWritten = \(progress.bytesWritten)")
130115
println("totalBytesWritten = \(progress.totalBytesWritten)")
131116
println("totalBytesExpectedToWrite = \(progress.totalBytesExpectedToWrite)")
117+
println()
132118

133-
}.then { (value: String) -> Void in
134-
135-
XCTAssertEqual(value, "OK")
136-
119+
}.then { value, errorInfo -> Void in
137120
expect.fulfill()
138121
}
139122

@@ -155,10 +138,6 @@ class AlamofireTests: _TestCase
155138

156139
.response { (request, response, data, error) in
157140

158-
println(request)
159-
println(response)
160-
println(error)
161-
162141
if let error = error {
163142
reject(error)
164143
return
@@ -172,12 +151,8 @@ class AlamofireTests: _TestCase
172151

173152
}
174153

175-
// set then
176-
task.then { (value: String) -> Void in
177-
178-
XCTAssertEqual(value, "OK")
179-
XCTAssertEqual(nsProgress.completedUnitCount, 50)
180-
154+
task.then { value, errorInfo -> Void in
155+
XCTAssertTrue(nsProgress.completedUnitCount == 50)
181156
expect.fulfill()
182157
}
183158

@@ -195,7 +170,7 @@ class AlamofireTests: _TestCase
195170
// nsurlsession - (NSURLSessionDownloadTask cancelByProducingResumeData) crashes nsnetwork daemon iOS 7.0 - Stack Overflow
196171
// http://stackoverflow.com/questions/25297750/nsurlsessiondownloadtask-cancelbyproducingresumedata-crashes-nsnetwork-daemon
197172
//
198-
func __testCancel()
173+
func testCancel()
199174
{
200175
var expect = self.expectationWithDescription(__FUNCTION__)
201176

@@ -205,10 +180,6 @@ class AlamofireTests: _TestCase
205180

206181
.response { (request, response, data, error) in
207182

208-
println(request)
209-
println(response)
210-
println(error)
211-
212183
if let error = error {
213184
reject(error)
214185
return
@@ -228,14 +199,12 @@ class AlamofireTests: _TestCase
228199

229200
} // end of 1st task definition (NOTE: don't chain with `then` or `failure` for 1st task cancellation)
230201

231-
task.then { (value: String?) -> Void in
202+
task.success { (value: String?) -> Void in
232203

233204
XCTFail("Should never reach here because task is cancelled.")
234205

235206
}.failure { (error: NSError?, isCancelled: Bool) -> Void in
236207

237-
// println(error)
238-
239208
XCTAssertTrue(error == nil, "Should receive nil error via task.cancel().")
240209
XCTAssertTrue(isCancelled)
241210

0 commit comments

Comments
 (0)