Skip to content

Commit 295c58b

Browse files
added test for deleting of data on close
1 parent 48f1241 commit 295c58b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/basic_shared_test.dart

+22
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ void main() {
2727
});
2828
}
2929

30+
test('should not delete data on close', () async {
31+
final db = await testUtils.setupDatabase(path: path);
32+
await createTables(db);
33+
34+
await db
35+
.execute('INSERT INTO test_data(description) VALUES(?)', ['test']);
36+
37+
final initialItems = await db.getAll('SELECT * FROM test_data');
38+
expect(initialItems.rows.length, greaterThan(0));
39+
40+
await db.close();
41+
42+
final db2 = await testUtils.setupDatabase(path: path);
43+
// This could also be a get call with an exception
44+
final table2 = await db2.getAll(
45+
"SELECT name FROM sqlite_master WHERE type='table' AND name='test_data';");
46+
expect(table2.rows.length, greaterThan(0),
47+
reason: "Table should be persisted from last connection");
48+
49+
await db2.close();
50+
});
51+
3052
test('should not allow direct db calls within a transaction callback',
3153
() async {
3254
final db = await testUtils.setupDatabase(path: path);

0 commit comments

Comments
 (0)