Skip to content

Commit d2059ab

Browse files
remove tests that were duplicated to test GET
(These are no longer necessary)
1 parent 484743f commit d2059ab

1 file changed

Lines changed: 8 additions & 283 deletions

File tree

Tests/ApolloCacheDependentTests/FetchQueryTests.swift

Lines changed: 8 additions & 283 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ApolloTestSupport
44
import StarWarsAPI
55

66
class FetchQueryTests: XCTestCase {
7-
func testFetchIgnoringCacheDataWithPOST() throws {
7+
func testFetchIgnoringCacheData() throws {
88
let query = HeroNameQuery()
99

1010
let initialRecords: RecordSet = [
@@ -84,47 +84,8 @@ class FetchQueryTests: XCTestCase {
8484
self.waitForExpectations(timeout: 5, handler: nil)
8585
}
8686
}
87-
88-
func testFetchIgnoringCacheDataWithGET() throws {
89-
let query = HeroNameQuery()
90-
91-
let initialRecords: RecordSet = [
92-
"QUERY_ROOT": ["hero": Reference(key: "hero")],
93-
"hero": [
94-
"name": "R2-D2",
95-
"__typename": "Droid",
96-
]
97-
]
98-
99-
withCache(initialRecords: initialRecords) { cache in
100-
let store = ApolloStore(cache: cache)
101-
102-
let networkTransport = MockNetworkTransport(body: [
103-
"data": [
104-
"hero": [
105-
"name": "Luke Skywalker",
106-
"__typename": "Human"
107-
]
108-
]
109-
])
110-
111-
let client = ApolloClient(networkTransport: networkTransport, store: store)
112-
113-
let expectation = self.expectation(description: "Fetching query")
114-
115-
client.fetch(query: query, cachePolicy: .fetchIgnoringCacheData) { (result, error) in
116-
defer { expectation.fulfill() }
117-
118-
guard let result = result else { XCTFail("No query result"); return }
119-
120-
XCTAssertEqual(result.data?.hero?.name, "Luke Skywalker")
121-
}
122-
123-
self.waitForExpectations(timeout: 5, handler: nil)
124-
}
125-
}
12687

127-
func testReturnCacheDataElseFetchWithCachedDataWithPOST() throws {
88+
func testReturnCacheDataElseFetchWithCachedData() throws {
12889
let query = HeroNameQuery()
12990

13091
let initialRecords: RecordSet = [
@@ -162,47 +123,8 @@ class FetchQueryTests: XCTestCase {
162123
self.waitForExpectations(timeout: 5, handler: nil)
163124
}
164125
}
165-
166-
func testReturnCacheDataElseFetchWithCachedDataWithGET() throws {
167-
let query = HeroNameQuery()
168-
169-
let initialRecords: RecordSet = [
170-
"QUERY_ROOT": ["hero": Reference(key: "QUERY_ROOT.hero")],
171-
"QUERY_ROOT.hero": [
172-
"name": "R2-D2",
173-
"__typename": "Droid",
174-
]
175-
]
176-
177-
withCache(initialRecords: initialRecords) { (cache) in
178-
let store = ApolloStore(cache: cache)
179-
180-
let networkTransport = MockNetworkTransport(body: [
181-
"data": [
182-
"hero": [
183-
"name": "Luke Skywalker",
184-
"__typename": "Human"
185-
]
186-
]
187-
])
188-
189-
let client = ApolloClient(networkTransport: networkTransport, store: store)
190-
191-
let expectation = self.expectation(description: "Fetching query")
192-
193-
client.fetch(query: query, cachePolicy: .returnCacheDataElseFetch) { (result, error) in
194-
defer { expectation.fulfill() }
195-
196-
guard let result = result else { XCTFail("No query result"); return }
197-
198-
XCTAssertEqual(result.data?.hero?.name, "R2-D2")
199-
}
200-
201-
self.waitForExpectations(timeout: 5, handler: nil)
202-
}
203-
}
204126

205-
func testReturnCacheDataElseFetchWithMissingDataWithPOST() throws {
127+
func testReturnCacheDataElseFetchWithMissingData() throws {
206128
let query = HeroNameQuery()
207129

208130
let initialRecords: RecordSet = [
@@ -239,46 +161,8 @@ class FetchQueryTests: XCTestCase {
239161
self.waitForExpectations(timeout: 5, handler: nil)
240162
}
241163
}
242-
243-
func testReturnCacheDataElseFetchWithMissingDataWithGET() throws {
244-
let query = HeroNameQuery()
245-
246-
let initialRecords: RecordSet = [
247-
"QUERY_ROOT": ["hero": Reference(key: "hero")],
248-
"hero": [
249-
"name": "R2-D2",
250-
]
251-
]
252-
253-
withCache(initialRecords: initialRecords) { (cache) in
254-
let store = ApolloStore(cache: cache)
255-
256-
let networkTransport = MockNetworkTransport(body: [
257-
"data": [
258-
"hero": [
259-
"name": "Luke Skywalker",
260-
"__typename": "Human"
261-
]
262-
]
263-
])
264-
265-
let client = ApolloClient(networkTransport: networkTransport, store: store)
266-
267-
let expectation = self.expectation(description: "Fetching query")
268-
269-
client.fetch(query: query, cachePolicy: .returnCacheDataElseFetch) { (result, error) in
270-
defer { expectation.fulfill() }
271-
272-
guard let result = result else { XCTFail("No query result"); return }
273-
274-
XCTAssertEqual(result.data?.hero?.name, "Luke Skywalker")
275-
}
276-
277-
self.waitForExpectations(timeout: 5, handler: nil)
278-
}
279-
}
280164

281-
func testReturnCacheDataDontFetchWithCachedDataWithPOST() throws {
165+
func testReturnCacheDataDontFetchWithCachedData() throws {
282166
let query = HeroNameQuery()
283167

284168
let initialRecords: RecordSet = [
@@ -314,49 +198,10 @@ class FetchQueryTests: XCTestCase {
314198
}
315199

316200
self.waitForExpectations(timeout: 5, handler: nil)
317-
}
318-
}
319-
320-
func testReturnCacheDataDontFetchWithCachedDataWithGET() throws {
321-
let query = HeroNameQuery()
322-
323-
let initialRecords: RecordSet = [
324-
"QUERY_ROOT": ["hero": Reference(key: "hero")],
325-
"hero": [
326-
"name": "R2-D2",
327-
"__typename": "Droid",
328-
]
329-
]
330-
331-
withCache(initialRecords: initialRecords) { (cache) in
332-
let store = ApolloStore(cache: cache)
333-
334-
let networkTransport = MockNetworkTransport(body: [
335-
"data": [
336-
"hero": [
337-
"name": "Luke Skywalker",
338-
"__typename": "Human"
339-
]
340-
]
341-
])
342-
343-
let client = ApolloClient(networkTransport: networkTransport, store: store)
344-
345-
let expectation = self.expectation(description: "Fetching query")
346-
347-
client.fetch(query: query, cachePolicy: .returnCacheDataDontFetch) { (result, error) in
348-
defer { expectation.fulfill() }
349-
350-
guard let result = result else { XCTFail("No query result"); return }
351-
352-
XCTAssertEqual(result.data?.hero?.name, "R2-D2")
353-
}
354-
355-
self.waitForExpectations(timeout: 5, handler: nil)
356201
}
357202
}
358203

359-
func testClearCacheWithPOST() throws {
204+
func testClearCache() throws {
360205
let query = HeroNameQuery()
361206

362207
let initialRecords: RecordSet = [
@@ -405,58 +250,8 @@ class FetchQueryTests: XCTestCase {
405250
self.waitForExpectations(timeout: 5, handler: nil)
406251
}
407252
}
408-
409-
func testClearCacheWithGET() throws {
410-
let query = HeroNameQuery()
411-
412-
let initialRecords: RecordSet = [
413-
"QUERY_ROOT": ["hero": Reference(key: "hero")],
414-
"hero": [
415-
"name": "R2-D2",
416-
"__typename": "Droid",
417-
]
418-
]
419-
420-
withCache(initialRecords: initialRecords) { (cache) in
421-
let store = ApolloStore(cache: cache)
422-
423-
let networkTransport = MockNetworkTransport(body: [
424-
"data": [
425-
"hero": [
426-
"name": "Luke Skywalker",
427-
"__typename": "Human"
428-
]
429-
]
430-
])
431-
432-
let client = ApolloClient(networkTransport: networkTransport, store: store)
433-
434-
let expectation = self.expectation(description: "Fetching query")
435-
436-
client.fetch(query: query, cachePolicy: .returnCacheDataDontFetch) { (result, error) in
437-
defer { expectation.fulfill() }
438-
guard let result = result else { XCTFail("No query result"); return }
439-
XCTAssertEqual(result.data?.hero?.name, "R2-D2")
440-
}
441-
442-
self.waitForExpectations(timeout: 5, handler: nil)
443-
444-
do { try client.clearCache().await() }
445-
catch { XCTFail() }
446-
447-
let expectation2 = self.expectation(description: "Fetching query")
448-
449-
client.fetch(query: query, cachePolicy: .returnCacheDataDontFetch) { (result, error) in
450-
defer { expectation2.fulfill() }
451-
XCTAssertNil(result)
452-
XCTAssertNil(error)
453-
}
454-
455-
self.waitForExpectations(timeout: 5, handler: nil)
456-
}
457-
}
458253

459-
func testReturnCacheDataDontFetchWithMissingDataWithPost() throws {
254+
func testReturnCacheDataDontFetchWithMissingData() throws {
460255
let query = HeroNameQuery()
461256

462257
let initialRecords: RecordSet = [
@@ -476,7 +271,7 @@ class FetchQueryTests: XCTestCase {
476271
"__typename": "Human"
477272
]
478273
]
479-
])
274+
])
480275

481276
let client = ApolloClient(networkTransport: networkTransport, store: store)
482277

@@ -493,77 +288,7 @@ class FetchQueryTests: XCTestCase {
493288
}
494289
}
495290

496-
func testReturnCacheDataDontFetchWithMissingDataWithGET() throws {
497-
let query = HeroNameQuery()
498-
499-
let initialRecords: RecordSet = [
500-
"QUERY_ROOT": ["hero": Reference(key: "hero")],
501-
"hero": [
502-
"name": "R2-D2",
503-
]
504-
]
505-
506-
withCache(initialRecords: initialRecords) { (cache) in
507-
let store = ApolloStore(cache: cache)
508-
509-
let networkTransport = MockNetworkTransport(body: [
510-
"data": [
511-
"hero": [
512-
"name": "Luke Skywalker",
513-
"__typename": "Human"
514-
]
515-
]
516-
])
517-
518-
let client = ApolloClient(networkTransport: networkTransport, store: store)
519-
520-
let expectation = self.expectation(description: "Fetching query")
521-
522-
client.fetch(query: query, cachePolicy: .returnCacheDataDontFetch) { (result, error) in
523-
defer { expectation.fulfill() }
524-
525-
XCTAssertNil(error)
526-
XCTAssertNil(result)
527-
}
528-
529-
self.waitForExpectations(timeout: 5, handler: nil)
530-
}
531-
}
532-
533-
func testCompletionHandlerIsCalledOnTheSpecifiedQueueWithPOST() {
534-
let queue = DispatchQueue(label: "label")
535-
536-
let key = DispatchSpecificKey<Void>()
537-
queue.setSpecific(key: key, value: ())
538-
539-
let query = HeroNameQuery()
540-
541-
let networkTransport = MockNetworkTransport(body: [
542-
"data": [
543-
"hero": [
544-
"name": "Luke Skywalker",
545-
"__typename": "Human"
546-
]
547-
]
548-
])
549-
550-
withCache { (cache) in
551-
let store = ApolloStore(cache: cache)
552-
let client = ApolloClient(networkTransport: networkTransport, store: store)
553-
554-
let expectation = self.expectation(description: "Fetching query")
555-
556-
client.fetch(query: query, cachePolicy: .fetchIgnoringCacheData, queue: queue) { (result, error) in
557-
defer { expectation.fulfill() }
558-
559-
XCTAssertNotNil(DispatchQueue.getSpecific(key: key))
560-
}
561-
562-
waitForExpectations(timeout: 5, handler: nil)
563-
}
564-
}
565-
566-
func testCompletionHandlerIsCalledOnTheSpecifiedQueueWithGET() {
291+
func testCompletionHandlerIsCalledOnTheSpecifiedQueue() {
567292
let queue = DispatchQueue(label: "label")
568293

569294
let key = DispatchSpecificKey<Void>()

0 commit comments

Comments
 (0)