summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/migration/test_current_from_v74.js
blob: eeb862daf542eede166ad0b895b98e36f29694f4 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function setup() {
  let path = await setupPlacesDatabase("places_v74.sqlite");
  let db = await Sqlite.openConnection({ path });
  await db.execute(`
  INSERT INTO moz_origins (id, prefix, host, frecency, recalc_frecency)
  VALUES
    (100, 'https://', 'test1.com', 0, 0),
    (101, 'https://', 'test2.com', 0, 0),
    (102, 'https://', 'test3.com', 0, 0)
  `);
  await db.close();
});

add_task(async function database_is_valid() {
  // Accessing the database for the first time triggers migration.
  Assert.equal(
    PlacesUtils.history.databaseStatus,
    PlacesUtils.history.DATABASE_STATUS_UPGRADED
  );

  const db = await PlacesUtils.promiseDBConnection();
  Assert.equal(await db.getSchemaVersion(), CURRENT_SCHEMA_VERSION);

  await db.execute("SELECT * FROM moz_places_extra");
  await db.execute("SELECT * from moz_historyvisits_extra");
});

add_task(async function recalc_origins_frecency() {
  const db = await PlacesUtils.promiseDBConnection();
  Assert.equal(await db.getSchemaVersion(), CURRENT_SCHEMA_VERSION);

  Assert.equal(
    (
      await db.execute(
        "SELECT count(*) FROM moz_origins WHERE recalc_frecency = 0"
      )
    )[0].getResultByIndex(0),
    0,
    "All entries should be set for recalculation"
  );
});