1
1
import 'dart:io' ;
2
+
2
3
import 'package:flutter_test/flutter_test.dart' ;
3
4
import 'package:json_cache/src/json_cache_safe_local_storage.dart' ;
4
5
import 'package:safe_local_storage/safe_local_storage.dart' ;
@@ -109,6 +110,16 @@ void main() {
109
110
// Check for multiple data.
110
111
expect (await jsonCacheSafeLocalStorage.contains (profKey), true );
111
112
expect (await jsonCacheSafeLocalStorage.contains (prefKey), true );
113
+
114
+ // Remove data from the cache.
115
+ await jsonCacheSafeLocalStorage.remove (profKey);
116
+ expect (await jsonCacheSafeLocalStorage.contains (profKey), false );
117
+ expect (await jsonCacheSafeLocalStorage.contains (prefKey), true );
118
+
119
+ // Remove data from the cache.
120
+ await jsonCacheSafeLocalStorage.remove (prefKey);
121
+ expect (await jsonCacheSafeLocalStorage.contains (profKey), false );
122
+ expect (await jsonCacheSafeLocalStorage.contains (prefKey), false );
112
123
},
113
124
);
114
125
@@ -119,12 +130,15 @@ void main() {
119
130
await jsonCacheSafeLocalStorage.refresh (profKey, profData);
120
131
await jsonCacheSafeLocalStorage.refresh (prefKey, prefData);
121
132
122
- // Clear it.
133
+ // Clear it. All data should be deleted with the file.
123
134
await jsonCacheSafeLocalStorage.clear ();
124
135
125
136
// No data should remain in the cache.
126
137
final cachedValue = await jsonCacheSafeLocalStorage.value (profKey);
127
138
expect (cachedValue, isNull);
139
+
140
+ // Insert a single piece of data into the cache. This refresh avoids errors on operational systems.
141
+ await jsonCacheSafeLocalStorage.refresh (profKey, profData);
128
142
},
129
143
);
130
144
},
@@ -133,7 +147,6 @@ void main() {
133
147
tearDown (
134
148
() async {
135
149
await storage.delete ();
136
- await tempDir.delete_ ();
137
150
},
138
151
);
139
152
}
0 commit comments