summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/tests/unit/test_MigrationUtils_timedRetry.js
blob: 12ca5a7b1d62a8000bb2fc35abab47eabf68f10e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use strict";

let tmpFile = FileUtils.getDir("TmpD", [], true);
let dbConn;

add_task(async function setup() {
  tmpFile.append("TestDB");
  dbConn = await Sqlite.openConnection({ path: tmpFile.path });

  registerCleanupFunction(async () => {
    await dbConn.close();
    await IOUtils.remove(tmpFile.path);
  });
});

add_task(async function testgetRowsFromDBWithoutLocksRetries() {
  let deferred = PromiseUtils.defer();
  let promise = MigrationUtils.getRowsFromDBWithoutLocks(
    tmpFile.path,
    "Temp DB",
    "SELECT * FROM moz_temp_table",
    deferred.promise
  );
  await new Promise(resolve => do_timeout(50, resolve));
  dbConn
    .execute("CREATE TABLE moz_temp_table (id INTEGER PRIMARY KEY)")
    .then(deferred.resolve);
  await promise;
});