Debian Codegraph @

maz-db/tests/qml/tst_database.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 Item {
7 id: test
8 width: 640
9 height: 480
10
11 MazDB {
12 id: db
13 }
14
15 MazDB {
16 id: db2
17 }
18
19 TestCase {
20 name: "MazDB"
21
22 property string source: Qt.resolvedUrl("~/.maztest.db")
23
24 function initTestCase() {
25 db.source = source
26 }
27
28 function cleanupTestCase() {
29 db.destroyDB(source)
30 }
31
32 function test_create() {
33 compare(db.opened, true, db.errorString)
34 }
35
36 function test_destroy() {
37 db2.source = "/tmp/test2.db"
38 compare(db2.opened, true, db2.errorString)
39 compare(db2.destroyDB("/tmp/test2.db"), true, db.errorString)
40 }
41
42 function test_get_default(){
43 compare(db.opened, true, db.errorString)
44 compare(db.get("invalidKey", [{"id": "a"}]), [{"id": "a"}])
45 }
46
47 function test_delete(){
48 compare(db.opened, true, db.errorString)
49 compare(db.put("asdf", ["asdf"]), true)
50 compare(db.del("asdf"), true)
51 compare(db.get("asdf"), undefined)
52 }
53 }
54 }