@@ -7,6 +7,7 @@ import com.apollographql.apollo.api.json.jsonReader
7
7
import com.apollographql.apollo.api.parseJsonResponse
8
8
import com.apollographql.apollo.benchmark.Utils.dbFile
9
9
import com.apollographql.apollo.benchmark.Utils.dbName
10
+ import com.apollographql.apollo.benchmark.Utils.largeListQuery
10
11
import com.apollographql.apollo.benchmark.Utils.operationBasedQuery
11
12
import com.apollographql.apollo.benchmark.Utils.registerCacheSize
12
13
import com.apollographql.apollo.benchmark.Utils.resource
@@ -25,25 +26,35 @@ class CacheIncubatingTests {
25
26
26
27
@Test
27
28
fun cacheOperationMemory () {
28
- readFromCache(" cacheOperationMemory" , operationBasedQuery, sql = false , Utils ::checkOperationBased)
29
+ readFromCache(" cacheOperationMemory" , operationBasedQuery, R .raw.calendar_response, sql = false , Utils ::checkOperationBased)
29
30
}
30
31
31
32
@Test
32
33
fun cacheOperationSql () {
33
- readFromCache(" cacheOperationSql" , operationBasedQuery, sql = true , Utils ::checkOperationBased)
34
+ readFromCache(" cacheOperationSql" , operationBasedQuery, R .raw.calendar_response, sql = true , Utils ::checkOperationBased)
34
35
}
35
36
36
37
@Test
37
38
fun cacheResponseMemory () {
38
- readFromCache(" cacheResponseMemory" , responseBasedQuery, sql = false , Utils ::checkResponseBased)
39
+ readFromCache(" cacheResponseMemory" , responseBasedQuery, R .raw.calendar_response, sql = false , Utils ::checkResponseBased)
39
40
}
40
41
41
42
@Test
42
43
fun cacheResponseSql () {
43
- readFromCache(" cacheResponseSql" , responseBasedQuery, sql = true , Utils ::checkResponseBased)
44
+ readFromCache(" cacheResponseSql" , responseBasedQuery, R .raw.calendar_response, sql = true , Utils ::checkResponseBased)
44
45
}
45
46
46
- private fun <D : Query .Data > readFromCache (testName : String , query : Query <D >, sql : Boolean , check : (D ) -> Unit ) {
47
+ @Test
48
+ fun cacheLargeListMemory () {
49
+ readFromCache(" cacheLargeListMemory" , largeListQuery, R .raw.tracks_playlist_response, sql = false , Utils ::checkLargeList)
50
+ }
51
+
52
+ @Test
53
+ fun cacheLargeListSql () {
54
+ readFromCache(" cacheLargeListSql" , largeListQuery, R .raw.tracks_playlist_response, sql = true , Utils ::checkLargeList)
55
+ }
56
+
57
+ private fun <D : Query .Data > readFromCache (testName : String , query : Query <D >, jsonResponseResId : Int , sql : Boolean , check : (D ) -> Unit ) {
47
58
val store = ApolloStore (
48
59
if (sql) {
49
60
dbFile.delete()
@@ -53,7 +64,7 @@ class CacheIncubatingTests {
53
64
}
54
65
)
55
66
56
- val data = query.parseJsonResponse(resource(R .raw.calendar_response ).jsonReader()).data!!
67
+ val data = query.parseJsonResponse(resource(jsonResponseResId ).jsonReader()).data!!
57
68
runBlocking {
58
69
store.writeOperation(query, data)
59
70
}
0 commit comments