Debian Codegraph @

maz-db/tests/qml/tst_propogation.qml

raw
1 import QtQuick 2.4
2 import QtQuick.Window 2.1
3 import QtTest 1.0
4 import MazDB 1.0
5
6 TestCase {
7 id: test
8 name: "MazDB::Propogation"
9 property string source: Qt.resolvedUrl("~/.maztest.db")
10
11 MazDB {
12 id: db
13 }
14
15 MazDB {
16 id: db2
17 }
18
19 SignalSpy {
20 id: spy1
21 target: db2
22 signalName: "keyValueChanged"
23 }
24
25 function initTestCase() {
26 db.source = test.source
27 db2.source = test.source
28 }
29
30 function cleanupTestCase() {
31 db2.close()
32 db.destroyDB(test.source)
33 }
34
35 function init() {
36 if (spy1.count) {
37 spy1.clear()
38 }
39 }
40
41 function test_propogate_value_changes() {
42 compare(db.opened, true, db.errorString)
43 compare(db2.opened, true, db2.errorString)
44 compare(db.putSync("newkey", "value"), true, "should be ok")
45 compare(spy1.count, 1, "Should have only had one keyvalue change")
46 compare(db2.get("newkey"), "value", "Data corruption... yuk!")
47 }
48
49 }
50