Merge lp:~kalikiana/u1db-qt/testfixes into lp:u1db-qt

Proposed by Cris Dywan
Status: Merged
Approved by: Cris Dywan
Approved revision: 91
Merged at revision: 84
Proposed branch: lp:~kalikiana/u1db-qt/testfixes
Merge into: lp:u1db-qt
Diff against target: 171 lines (+27/-23)
6 files modified
src/database.cpp (+4/-2)
src/query.cpp (+12/-1)
tests/CMakeLists.txt (+1/-1)
tests/strict-qmltestrunner (+3/-0)
tests/tst_database.qml (+1/-12)
tests/tst_query.qml (+6/-7)
To merge this branch: bzr merge lp:~kalikiana/u1db-qt/testfixes
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+161510@code.launchpad.net

Commit message

Enable and fix number and defaults behavior

Description of the change

Enable and fix number and defaults behavior

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
lp:~kalikiana/u1db-qt/testfixes updated
88. By Cris Dywan

Ensure connection isn't re-used and test expected warnings

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~kalikiana/u1db-qt/testfixes updated
89. By Cris Dywan

Wrap qmltestrunner instead of a separate warning test case

90. By Cris Dywan

Correct keyword query test definitions

91. By Cris Dywan

Emit warnings on unexpected types in query

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/database.cpp'
2--- src/database.cpp 2013-04-23 15:17:24 +0000
3+++ src/database.cpp 2013-04-30 15:47:26 +0000
4@@ -74,7 +74,7 @@
5 bool
6 Database::setError(const QString& error)
7 {
8- qDebug() << "u1db: " << error;
9+ qWarning("u1db: %s", qPrintable(error));
10 m_error = error;
11 Q_EMIT errorChanged(error);
12 return false;
13@@ -103,8 +103,10 @@
14 if (m_db.isOpen())
15 return true;
16
17+ /* A unique ID is used for the connection name to ensure that we aren't
18+ re-using or replacing other opend databases. */
19 if (!m_db.isValid())
20- m_db = QSqlDatabase::addDatabase("QSQLITE");
21+ m_db = QSqlDatabase::addDatabase("QSQLITE", QUuid::createUuid().toString());
22 if (!m_db.isValid())
23 return setError("QSqlDatabase error");
24 m_db.setDatabaseName(path);
25
26=== modified file 'src/query.cpp'
27--- src/query.cpp 2013-04-25 14:03:04 +0000
28+++ src/query.cpp 2013-04-30 15:47:26 +0000
29@@ -164,18 +164,27 @@
30
31 QString value_string = value.toString();
32 QVariant query = getQuery();
33+ // * is the default if query is empty
34+ if (!query.isValid())
35+ query = QVariant(QString("*"));
36 QString typeName = query.typeName();
37
38-
39 if(typeName == "QString")
40 {
41 QString query_string = query.toString();
42 match = queryString(query_string, value_string);
43 }
44+ else if(typeName == "int")
45+ {
46+ QString query_string = query.toString();
47+ match = queryString(query_string, value_string);
48+ }
49 else if(typeName == "QVariantList")
50 {
51 match = iterateQueryList(query, field, value_string);
52 }
53+ else
54+ qWarning("u1db: Unexpected type %s", qPrintable(typeName));
55
56 return match;
57
58@@ -217,6 +226,8 @@
59 }
60
61 }
62+ else
63+ qWarning("u1db: Unexpected type %s", qPrintable(typeName));
64
65 }
66
67
68=== modified file 'tests/CMakeLists.txt'
69--- tests/CMakeLists.txt 2013-04-24 09:02:41 +0000
70+++ tests/CMakeLists.txt 2013-04-30 15:47:26 +0000
71@@ -2,7 +2,7 @@
72
73 find_package(Qt5Test REQUIRED)
74
75-add_test(NAME plugintest COMMAND "qmltestrunner" "-maxwarnings" "20" "-platform" "minimal" "-import" "../modules" "-xunitxml" "-o" "plugintest-xunit.xml" "-input" "${CMAKE_CURRENT_SOURCE_DIR}")
76+add_test(NAME plugintest COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/strict-qmltestrunner" "-platform" "minimal" "-import" "../modules" "-xunitxml" "-o" "plugintest-xunit.xml" "-input" "${CMAKE_CURRENT_SOURCE_DIR}")
77
78 include_directories(
79 ${CMAKE_CURRENT_BINARY_DIR}
80
81=== added file 'tests/strict-qmltestrunner'
82--- tests/strict-qmltestrunner 1970-01-01 00:00:00 +0000
83+++ tests/strict-qmltestrunner 2013-04-30 15:47:26 +0000
84@@ -0,0 +1,3 @@
85+#!/usr/bin/env sh
86+qmltestrunner $* || exit 1
87+test 0 -eq $(grep -c qwarn plugintest-xunit.xml) || exit 1
88
89=== modified file 'tests/tst_database.qml'
90--- tests/tst_database.qml 2013-04-22 13:26:42 +0000
91+++ tests/tst_database.qml 2013-04-30 15:47:26 +0000
92@@ -59,18 +59,6 @@
93 delegate: Text {
94 x: 66; y: 77
95 text: "otherDelegate index:%1".arg(index)
96- // text: "myDelegate index:%1 docId:%2 contents:%3".arg(index).arg(docId).arg(contents)
97- }
98- }
99-
100- ListView {
101- id: otherList
102- model: firstQuery
103- width: 200; height: 200
104- delegate: Text {
105- x: 66; y: 77
106- text: "otherDelegate index:%1".arg(index)
107- // text: "otherDelegate index:%1 docId:%2 contents:%3".arg(index).arg(docId).arg(contents)
108 }
109 }
110
111@@ -98,6 +86,7 @@
112 }
113
114 function test_2_databaseError () {
115+ ignoreWarning('u1db: Invalid docID 日本語')
116 myDatabase.putDoc({"": ""}, "日本語")
117 spyErrorChanged.wait()
118 compare(myDatabase.error.indexOf("Invalid docID") > -1, true)
119
120=== modified file 'tests/tst_query.qml'
121--- tests/tst_query.qml 2013-04-25 13:38:33 +0000
122+++ tests/tst_query.qml 2013-04-30 15:47:26 +0000
123@@ -80,7 +80,7 @@
124 U1db.Query {
125 id: allPhoneKeywords
126 index: byPhone
127- query: { 'phone': '*' }
128+ query: [ { 'phone': '*' } ]
129 }
130
131 U1db.Query {
132@@ -110,7 +110,7 @@
133 U1db.Query {
134 id: ivankaAllNamePhoneKeywords
135 index: byNamePhone
136- query: { 'name': 'Ivanka', 'phone': '*' }
137+ query: [ { 'name': 'Ivanka', 'phone': '*' } ]
138 }
139
140 SignalSpy {
141@@ -133,26 +133,25 @@
142
143 function test_1_defaults () {
144 // We should get all documents
145- /* FIXME: */ defaultPhone.query = '*'
146 workaroundQueryAndWait(defaultPhone)
147 compare(defaultPhone.documents, ['1', '_', 'a'], 'uno')
148- console.log(defaultPhone.results)
149 compare(defaultPhone.results.length, 5, 'dos')
150 // FIXME: compare(defaultPhone.results, [], 'dos')
151 // These queries are functionally equivalent
152 compare(defaultPhone.documents, allPhone.documents, 'tres')
153 compare(defaultPhone.documents, allPhoneList.documents, 'quatro')
154 workaroundQueryAndWait(allPhoneKeywords)
155- // FIXME: compare(defaultPhone.documents, allPhoneKeywords.documents, 'cinco')
156+ compare(defaultPhone.documents, allPhoneKeywords.documents, 'cinco')
157 // Results are also equivalent
158- // FIXME: compare(defaultPhone.results, allPhoneKeywords.results, 'seis')
159+ compare(defaultPhone.results.length, allPhoneKeywords.results.length , 'siete')
160+ compare(defaultPhone.results, allPhoneKeywords.results, 'seis')
161 }
162
163 function test_2_numbers () {
164 // We should get '1'
165 compare(s12345Phone.documents, ['1'], 'uno')
166 // It's okay to mix strings and numerical values
167- // FIXME: compare(s12345Phone.documents, i12345Phone.documents, 'dos')
168+ compare(s12345Phone.documents, i12345Phone.documents, 'dos')
169 }
170
171 function test_3_wildcards () {

Subscribers

People subscribed via source and target branches

to all changes: