@@ -4,7 +4,7 @@ import 'dart:convert';
44import 'package:http_cache_core/http_cache_core.dart' ;
55import 'package:test/test.dart' ;
66
7- Future <void > _addFooResponse (
7+ Future <void > addFooResponse (
88 CacheStore store, {
99 String key = 'foo' ,
1010 CacheControl ? cacheControl,
@@ -41,8 +41,17 @@ Future<void> emptyByDefault(CacheStore store) async {
4141}
4242
4343Future <void > addItem (CacheStore store) async {
44- await _addFooResponse (store);
45- expect (await store.exists ('foo' ), isTrue);
44+ await addFooResponse (store, priority: CachePriority .low);
45+ var resp = await store.get ('foo' );
46+ expect (resp? .priority, CachePriority .low);
47+
48+ await addFooResponse (store, priority: CachePriority .normal);
49+ resp = await store.get ('foo' );
50+ expect (resp? .priority, CachePriority .normal);
51+
52+ await addFooResponse (store, priority: CachePriority .high);
53+ resp = await store.get ('foo' );
54+ expect (resp? .priority, CachePriority .high);
4655}
4756
4857Future <void > getItem (CacheStore store) async {
@@ -53,7 +62,7 @@ Future<void> getItem(CacheStore store) async {
5362 final expires = DateTime .now ();
5463 final lastModified = HttpDate .format (DateTime .now ());
5564
56- await _addFooResponse (
65+ await addFooResponse (
5766 store,
5867 maxStale: DateTime .now ().add (const Duration (days: 1 )),
5968 headers: headers,
@@ -80,14 +89,14 @@ Future<void> getItem(CacheStore store) async {
8089}
8190
8291Future <void > deleteItem (CacheStore store) async {
83- await _addFooResponse (store);
92+ await addFooResponse (store);
8493 expect (await store.exists ('foo' ), isTrue);
8594
8695 await store.delete ('foo' );
8796 expect (await store.exists ('foo' ), isFalse);
8897 await store.delete ('foo' ); // check for non exception
8998
90- await _addFooResponse (
99+ await addFooResponse (
91100 store,
92101 maxStale: DateTime .now ().add (const Duration (days: 1 )),
93102 );
@@ -98,12 +107,12 @@ Future<void> deleteItem(CacheStore store) async {
98107}
99108
100109Future <void > clean (CacheStore store) async {
101- await _addFooResponse (
110+ await addFooResponse (
102111 store,
103112 key: 'not-stale' ,
104113 maxStale: DateTime .now ().add (const Duration (days: 1 )),
105114 );
106- await _addFooResponse (
115+ await addFooResponse (
107116 store,
108117 key: 'stale' ,
109118 maxStale: DateTime .now ().subtract (const Duration (days: 1 )),
@@ -127,7 +136,7 @@ Future<void> clean(CacheStore store) async {
127136
128137Future <void > expires (CacheStore store) async {
129138 final now = DateTime .now ();
130- await _addFooResponse (store, expires: DateTime .now ());
139+ await addFooResponse (store, expires: DateTime .now ());
131140 final resp = await store.get ('foo' );
132141 expect (
133142 resp! .expires! .subtract (
@@ -146,7 +155,7 @@ Future<void> expires(CacheStore store) async {
146155Future <void > lastModified (CacheStore store) async {
147156 final lastModified = 'Wed, 21 Oct 2015 07:28:00 GMT' ;
148157
149- await _addFooResponse (store, lastModified: lastModified);
158+ await addFooResponse (store, lastModified: lastModified);
150159 final resp = await store.get ('foo' );
151160 expect (resp! .lastModified, equals (lastModified));
152161}
@@ -159,7 +168,7 @@ Future<void> concurrentAccess(CacheStore store) async {
159168
160169 for (var i = 1 ; i <= max; i++ ) {
161170 final key = i % 3 == 0 ? 'bar' : 'foo' ;
162- _addFooResponse (store, key: key, lastModified: lastModified).then (
171+ addFooResponse (store, key: key, lastModified: lastModified).then (
163172 (value) {
164173 store.get (key).then (
165174 (resp) {
@@ -265,28 +274,28 @@ void pathExists(CacheStore store) {
265274}
266275
267276Future <void > deleteFromPath (CacheStore store) async {
268- await _addFooResponse (store);
277+ await addFooResponse (store);
269278 expect (await store.exists ('foo' ), isTrue);
270279 await store.deleteFromPath (RegExp ('https://foo.com' ));
271280 expect (await store.exists ('foo' ), isFalse);
272281
273- await _addFooResponse (store, url: 'https://foo.com?bar=bar' );
282+ await addFooResponse (store, url: 'https://foo.com?bar=bar' );
274283 expect (await store.exists ('foo' ), isTrue);
275284 await store.deleteFromPath (
276285 RegExp ('https://foo.com' ),
277286 queryParams: {'bar' : null },
278287 );
279288 expect (await store.exists ('foo' ), isFalse);
280289
281- await _addFooResponse (store, url: 'https://foo.com?bar=bar' );
290+ await addFooResponse (store, url: 'https://foo.com?bar=bar' );
282291 expect (await store.exists ('foo' ), isTrue);
283292 await store.deleteFromPath (
284293 RegExp ('https://foo.com' ),
285294 queryParams: {'bar' : 'bar' },
286295 );
287296 expect (await store.exists ('foo' ), isFalse);
288297
289- await _addFooResponse (store, url: 'https://foo.com?bar=bar' );
298+ await addFooResponse (store, url: 'https://foo.com?bar=bar' );
290299 expect (await store.exists ('foo' ), isTrue);
291300 await store.deleteFromPath (
292301 RegExp ('https://foo.com' ),
@@ -296,25 +305,25 @@ Future<void> deleteFromPath(CacheStore store) async {
296305}
297306
298307Future <void > getFromPath (CacheStore store) async {
299- await _addFooResponse (store);
308+ await addFooResponse (store);
300309 var list = await store.getFromPath (RegExp ('https://foo.com' ));
301310 expect (list.length, 1 );
302311
303- await _addFooResponse (store, url: 'https://foo.com?bar=bar' );
312+ await addFooResponse (store, url: 'https://foo.com?bar=bar' );
304313 list = await store.getFromPath (
305314 RegExp ('https://foo.com' ),
306315 queryParams: {'bar' : null },
307316 );
308317 expect (list.length, 1 );
309318
310- await _addFooResponse (store, url: 'https://foo.com?bar=bar' );
319+ await addFooResponse (store, url: 'https://foo.com?bar=bar' );
311320 list = await store.getFromPath (
312321 RegExp ('https://foo.com' ),
313322 queryParams: {'bar' : 'bar' },
314323 );
315324 expect (list.length, 1 );
316325
317- await _addFooResponse (store, url: 'https://foo.com?bar=bar' );
326+ await addFooResponse (store, url: 'https://foo.com?bar=bar' );
318327 list = await store.getFromPath (
319328 RegExp ('https://foo.com' ),
320329 queryParams: {'bar' : 'foobar' },
0 commit comments