Debian Codegraph @

maz-db/tests/qml/tst_batch.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::Batch"
9 property string source: Qt.resolvedUrl("~/.maztest.db")
10
11 MazDB {
12 id: db
13 }
14
15 function initTestCase() {
16 db.source = test.source
17 }
18
19 function cleanupTestCase() {
20 db.destroyDB(test.source)
21 }
22
23 function test_batch(){
24 compare(db.opened, true, db.errorString)
25 var status = db.batch()
26 .put("asdf","asdf")
27 .put("string", "asdf2")
28 .put("list", ["asdf"])
29 .put("object", {"a": "b"})
30 .del("asdf")
31 .write()
32 compare(status, true, "Batch Operation Failed")
33 compare(db.get("asdf"), undefined)
34 compare(db.get("string"),"asdf2", "Wrong data")
35 compare(db.get("list"),["asdf"], "Wrong data")
36 compare(db.get("object"),{"a": "b"}, "Wrong data")
37 }
38 }
39