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

Proposed by Cris Dywan
Status: Merged
Merge reported by: Cris Dywan
Merged at revision: not available
Proposed branch: lp:~kalikiana/u1db-qt/ordering
Merge into: lp:u1db-qt
Diff against target: 83 lines (+68/-0)
1 file modified
tests/tst_query.qml (+68/-0)
To merge this branch: bzr merge lp:~kalikiana/u1db-qt/ordering
Reviewer Review Type Date Requested Status
U1DB Qt developers Pending
Review via email: mp+183886@code.launchpad.net

Commit message

Unit test query bugs related to the ordering of fields

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/tst_query.qml'
2--- tests/tst_query.qml 2013-08-27 10:49:26 +0000
3+++ tests/tst_query.qml 2013-09-04 14:17:25 +0000
4@@ -120,6 +120,55 @@
5 query: [{ 'name': 'Ivanka', 'phone': '*' }]
6 }
7
8+ U1db.Database {
9+ id: tokusatsu
10+ }
11+
12+ U1db.Document {
13+ database: tokusatsu
14+ docId: 'ooo'
15+ contents: { 'series': 'ooo', 'type': 'rider' }
16+ }
17+
18+ U1db.Document {
19+ database: tokusatsu
20+ docId: 'gokaiger'
21+ contents: { 'series': 'gokaiger', 'type': 'sentai' }
22+ }
23+
24+ U1db.Document {
25+ id: tokusatsuDocumentWizard
26+ docId: 'wizard'
27+ contents: { 'series': 'wizard', 'type': 'rider',
28+ 'transformations': ['Flame Style','Water Style'] }
29+ }
30+
31+ U1db.Document {
32+ id: tokusatsuDocumentDino
33+ docId: 'dino'
34+ contents: { 'series': 'zyuranger', 'scarf': false, 'type': 'sentai',
35+ 'beasts': ['T-Rex', 'Mastodon'] }
36+ }
37+
38+ U1db.Index {
39+ id: bySeries
40+ database: tokusatsu
41+ name: 'by-series'
42+ expression: ['series', 'type']
43+ }
44+
45+ U1db.Query {
46+ id: allHeroesWithType
47+ index: bySeries
48+ query: [{ 'series': '*' }, { 'type': '*' }]
49+ }
50+
51+ U1db.Query {
52+ id: allHeroesSeriesOnly
53+ index: bySeries
54+ query: [{ 'series': '*' }]
55+ }
56+
57 SignalSpy {
58 id: spyDocumentsChanged
59 target: defaultPhone
60@@ -186,5 +235,24 @@
61 compare(defaultPhone.documents, ['1', 'a'], 'dos')
62 }
63
64+ function test_5_definition () {
65+ workaroundQueryAndWait(allHeroesWithType)
66+ compare(allHeroesWithType.documents, ['gokaiger', 'ooo'], 'ichi')
67+ workaroundQueryAndWait(allHeroesSeriesOnly)
68+ compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'ni')
69+ // Add a document with extra fields
70+ tokusatsu.putDoc(tokusatsuDocumentWizard.contents, tokusatsuDocumentWizard.docId)
71+ workaroundQueryAndWait(allHeroesWithType)
72+ compare(allHeroesWithType.documents, ['gokaiger', 'ooo', 'wizard'], 'san')
73+ workaroundQueryAndWait(allHeroesSeriesOnly)
74+ compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'chi')
75+ // Add a document with mixed custom fields
76+ tokusatsu.putDoc(tokusatsuDocumentDino.contents, tokusatsuDocumentDino.docId)
77+ workaroundQueryAndWait(allHeroesWithType)
78+ compare(allHeroesWithType.documents, ['gokaiger', 'ooo', 'wizard', 'dino'], 'go')
79+ workaroundQueryAndWait(allHeroesSeriesOnly)
80+ compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'roku')
81+ }
82+
83 } }
84

Subscribers

People subscribed via source and target branches

to all changes: