@@ -13,7 +13,7 @@ import 'test_env.dart';
13
13
14
14
void main () {
15
15
test ('store reference' , () {
16
- final env = TestEnv ('store' );
16
+ final env = TestEnv ('store-ref ' );
17
17
final store1 = env.store;
18
18
final store2 = Store .fromReference (getObjectBoxModel (), store1.reference);
19
19
expect (store1, isNot (store2));
@@ -31,19 +31,19 @@ void main() {
31
31
test ('store attach fails if same isolate' , () {
32
32
final env = TestEnv ('store' );
33
33
expect (
34
- () => Store .attach (getObjectBoxModel (), env.dir.path ),
34
+ () => Store .attach (getObjectBoxModel (), env.dbDirPath ),
35
35
throwsA (predicate ((UnsupportedError e) =>
36
36
e.message! .contains ('Cannot create multiple Store instances' ))));
37
37
env.closeAndDelete ();
38
38
});
39
39
40
40
test ('store attach remains open if main store closed' , () async {
41
- final env = TestEnv ('store' );
41
+ final env = TestEnv ('store-attach ' );
42
42
final store1 = env.store;
43
43
final receivePort = ReceivePort ();
44
44
final received = StreamQueue <dynamic >(receivePort);
45
45
await Isolate .spawn (storeAttachIsolate,
46
- StoreAttachIsolateInit (receivePort.sendPort, env.dir.path ));
46
+ StoreAttachIsolateInit (receivePort.sendPort, env.dbDirPath ));
47
47
final commandPort = await received.next as SendPort ;
48
48
49
49
// Check native instance pointer is different.
@@ -54,7 +54,7 @@ void main() {
54
54
expect (id, 1 );
55
55
// Close original store to test store remains open until all refs closed.
56
56
store1.close ();
57
- expect (true , Store .isOpen ('testdata-store' ) );
57
+ expect (Store .isOpen (env.dbDirPath), true );
58
58
59
59
// Read data with attached store.
60
60
commandPort.send (id);
@@ -65,14 +65,14 @@ void main() {
65
65
// Close attached store, should close store completely.
66
66
commandPort.send (null );
67
67
await received.next;
68
- expect (false , Store .isOpen ('testdata-store' ) );
68
+ expect (Store .isOpen (env.dbDirPath), false );
69
69
70
70
// Dispose StreamQueue.
71
71
await received.cancel ();
72
72
});
73
73
74
74
test ('store attach with configuration' , () {
75
- final env = TestEnv ('store' );
75
+ final env = TestEnv ('store-config ' );
76
76
// Get store config.
77
77
final storeConfig = env.store.configuration ();
78
78
expect (storeConfig.id, isNot (0 ));
@@ -102,18 +102,20 @@ void main() {
102
102
});
103
103
104
104
test ('store is open' , () {
105
- expect (false , Store .isOpen ('' ));
106
- expect (false , Store .isOpen ('testdata-store' ));
107
- final env = TestEnv ('store' );
108
- expect (false , env.store.isClosed ());
109
- expect (true , Store .isOpen ('testdata-store' ));
105
+ final name = 'store-open' ;
106
+ expect (Store .isOpen ('' ), false );
107
+ expect (Store .isOpen (TestEnv .testDbDirPath (false , name)), false );
108
+ expect (Store .isOpen (TestEnv .testDbDirPath (true , name)), false );
109
+ final env = TestEnv (name);
110
+ expect (env.store.isClosed (), false );
111
+ expect (Store .isOpen (env.dbDirPath), true );
110
112
env.closeAndDelete ();
111
- expect (true , env.store.isClosed ());
112
- expect (false , Store .isOpen ('testdata-store' ) );
113
+ expect (env.store.isClosed (), true );
114
+ expect (Store .isOpen (env.dbDirPath), false );
113
115
});
114
116
115
117
test ('transactions' , () {
116
- final env = TestEnv ('store' );
118
+ final env = TestEnv ('store-tx ' );
117
119
expect (TxMode .values.length, 2 );
118
120
for (var mode in TxMode .values) {
119
121
// Returned value falls through.
@@ -143,7 +145,7 @@ void main() {
143
145
});
144
146
145
147
test ('async transactions' , () async {
146
- final env = TestEnv ('store' );
148
+ final env = TestEnv ('store-async-tx ' );
147
149
expect (TxMode .values.length, 2 );
148
150
for (var mode in TxMode .values) {
149
151
// Returned value falls through.
@@ -346,7 +348,7 @@ void main() {
346
348
});
347
349
348
350
test ('store run in isolate' , () async {
349
- final env = TestEnv ('store' );
351
+ final env = TestEnv ('store-isolate ' );
350
352
final id = env.box.put (TestEntity (tString: 'foo' ));
351
353
final futureResult = env.store.runAsync (_readStringAndRemove, id);
352
354
print ('Count in main isolate: ${env .box .count ()}' );
@@ -357,7 +359,7 @@ void main() {
357
359
});
358
360
359
361
test ('store runAsync returns isolate error' , () async {
360
- final env = TestEnv ('store' );
362
+ final env = TestEnv ('store-run-async-isolate ' );
361
363
try {
362
364
await env.store.runAsync (_producesIsolateError, 'nothing' );
363
365
fail ("Should throw RemoteError" );
@@ -368,7 +370,7 @@ void main() {
368
370
});
369
371
370
372
test ('store runAsync returns callback error' , () async {
371
- final env = TestEnv ('store' );
373
+ final env = TestEnv ('store-run-async-callback ' );
372
374
try {
373
375
await env.store.runAsync (_producesCallbackError, 'nothing' );
374
376
fail ("Should throw error produced by callback" );
0 commit comments