System.Data.SQLite
Check-in [ac526d98e8]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor test cleanup.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: ac526d98e85c357dc40d7ca401cdf6b841801f22
User & Date: mistachkin 2017-10-12 00:03:47
Context
2017-10-12
19:26
Cleanup and modularize tests in preparation for stream variants. Initial work on stream tests. check-in: c41edbe55e user: mistachkin tags: sessions
00:03
Minor test cleanup. check-in: ac526d98e8 user: mistachkin tags: sessions
00:00
Add tests for LoadDifferencesFromTable and stream-based change set creation. check-in: e3f513c15d user: mistachkin tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Tests/session.eagle.

   194    194       CREATE TABLE ${databaseName}.t1(x INTEGER PRIMARY KEY, y TEXT);
   195    195       CREATE TABLE ${databaseName}.t2(x INTEGER PRIMARY KEY, y TEXT);
   196    196     }]
   197    197   }
   198    198   
   199    199   ###############################################################################
   200    200   
   201         -proc makeSomeChanges { db table types random {rowId ""} {count 5} } {
          201  +proc makeSomeChanges { db table types {rowId ""} {count 5} } {
   202    202     foreach type $types {
   203    203       switch -nocase -- $type {
   204    204         insert {
   205         -        set text [appendArgs "inserted: " [getSomeText $random $count]]
          205  +        set text [appendArgs "inserted: " [getSomeText false $count]]
   206    206   
   207    207           if {[string is integer -strict $rowId]} then {
   208    208             sql execute $db [subst {
   209    209               INSERT INTO ${table}(x, y) VALUES(?, ?);
   210    210             }] [list param1 Int32 $rowId] [list param2 String $text]
   211    211           } else {
   212    212             sql execute $db [subst {
   213    213               INSERT INTO ${table}(y) VALUES(?);
   214    214             }] [list param1 String $text]
   215    215           }
   216    216         }
   217    217         update {
   218         -        set text [appendArgs "updated: " [getSomeText $random $count]]
          218  +        set text [appendArgs "updated: " [getSomeText false $count]]
   219    219   
   220    220           if {[string is integer -strict $rowId]} then {
   221    221             sql execute $db [subst {
   222    222               UPDATE ${table} SET y = ? WHERE x = ?;
   223    223             }] [list param1 String $text] [list param2 Int32 $rowId]
   224    224           } else {
   225    225             sql execute $db [subst {
................................................................................
   341    341   
   342    342     set fileName(1) [getChangeSetFileName 1]
   343    343     set fileName(2) [getChangeSetFileName 2]
   344    344   
   345    345     cleanupSomeText
   346    346   } -body {
   347    347     createTheSchema $db main
   348         -  makeSomeChanges $db t1 [list insert insert] false
          348  +  makeSomeChanges $db t1 [list insert insert]
   349    349   
   350    350     set connection [getDbConnection]
   351    351   
   352    352     set session [$connection -alias CreateSession main]
   353    353     $session AttachTable null
   354    354   
   355         -  makeSomeChanges $db t1 [list insert update delete] false
          355  +  makeSomeChanges $db t1 [list insert update delete]
   356    356   
   357    357     set rawData [createChangeSetForSession $session]
   358    358     object removeref $rawData
   359    359   
   360    360     set stream(1) [object create -alias \
   361    361         System.IO.FileStream $fileName(1) Create Write]
   362    362   
................................................................................
   412    412   
   413    413   runTest {test session-1.2 {session change set enumeration} -setup {
   414    414     setupDb [set fileName session-1.2.db]
   415    415   
   416    416     cleanupSomeText
   417    417   } -body {
   418    418     createTheSchema $db main
   419         -  makeSomeChanges $db t1 [list insert insert insert] false
          419  +  makeSomeChanges $db t1 [list insert insert insert]
   420    420   
   421    421     set connection [getDbConnection]
   422    422   
   423    423     set session [$connection -alias CreateSession main]
   424    424     $session AttachTable null
   425    425   
   426         -  makeSomeChanges $db t1 [list insert update delete] false
          426  +  makeSomeChanges $db t1 [list insert update delete]
   427    427   
   428    428     set rawData [createChangeSetForSession $session]
   429    429     object removeref $rawData
   430    430   
   431    431     set changeSet(1) [$connection -alias CreateChangeSet $rawData]
   432    432     set changeSet(2) [$changeSet(1) -alias Invert]
   433    433   
................................................................................
   484    484   
   485    485   runTest {test session-1.3 {session enabled/disabled state} -setup {
   486    486     setupDb [set fileName session-1.3.db]
   487    487   
   488    488     cleanupSomeText
   489    489   } -body {
   490    490     createTheSchema $db main
   491         -  makeSomeChanges $db t1 [list insert] false
          491  +  makeSomeChanges $db t1 [list insert]
   492    492   
   493    493     set connection [getDbConnection]
   494    494   
   495    495     set session [$connection -alias CreateSession main]
   496    496     lappend result IsEnabled [$session IsEnabled]
   497    497   
   498    498     $session AttachTable null
   499    499     lappend result IsEnabled [$session IsEnabled]
   500    500   
   501    501     $session SetToDisabled
   502    502     lappend result IsEnabled [$session IsEnabled]
   503    503   
   504         -  makeSomeChanges $db t1 [list insert] false
          504  +  makeSomeChanges $db t1 [list insert]
   505    505     lappend result IsEmpty [$session IsEmpty]
   506    506   
   507    507     set rawData [createChangeSetForSession $session]
   508    508     object removeref $rawData
   509    509   
   510    510     lappend result Length [$rawData Length]
   511    511   
   512    512     $session SetToEnabled
   513    513     lappend result IsEnabled [$session IsEnabled]
   514    514   
   515         -  makeSomeChanges $db t1 [list insert] false
          515  +  makeSomeChanges $db t1 [list insert]
   516    516     lappend result IsEmpty [$session IsEmpty]
   517    517   
   518    518     set rawData [createChangeSetForSession $session]
   519    519     object removeref $rawData
   520    520   
   521    521     set changeSet(1) [$connection -alias CreateChangeSet $rawData]
   522    522     lappend result [changeSetToString $changeSet(1) false]
................................................................................
   543    543   
   544    544   runTest {test session-1.4 {session direct/indirect state} -setup {
   545    545     setupDb [set fileName session-1.4.db]
   546    546   
   547    547     cleanupSomeText
   548    548   } -body {
   549    549     createTheSchema $db main
   550         -  makeSomeChanges $db t1 [list insert] false
          550  +  makeSomeChanges $db t1 [list insert]
   551    551   
   552    552     set connection [getDbConnection]
   553    553   
   554    554     set session [$connection -alias CreateSession main]
   555    555     lappend result IsIndirect [$session IsIndirect]
   556    556   
   557    557     $session AttachTable null
   558    558     lappend result IsIndirect [$session IsIndirect]
   559    559   
   560    560     $session SetToIndirect
   561    561     lappend result IsIndirect [$session IsIndirect]
   562    562   
   563         -  makeSomeChanges $db t1 [list insert] false
          563  +  makeSomeChanges $db t1 [list insert]
   564    564     lappend result IsEmpty [$session IsEmpty]
   565    565   
   566    566     set rawData [createChangeSetForSession $session]
   567    567     object removeref $rawData
   568    568   
   569    569     $session SetToDirect
   570    570     lappend result IsIndirect [$session IsIndirect]
   571    571   
   572         -  makeSomeChanges $db t1 [list insert] false
          572  +  makeSomeChanges $db t1 [list insert]
   573    573     lappend result IsEmpty [$session IsEmpty]
   574    574   
   575    575     set rawData [createChangeSetForSession $session]
   576    576     object removeref $rawData
   577    577   
   578    578     set changeSet(1) [$connection -alias CreateChangeSet $rawData]
   579    579     lappend result [changeSetToString $changeSet(1) false]
................................................................................
   601    601   
   602    602   runTest {test session-1.5 {session table filter} -setup {
   603    603     setupDb [set fileName session-1.5.db]
   604    604   
   605    605     cleanupSomeText
   606    606   } -body {
   607    607     createTheSchema $db main
   608         -  makeSomeChanges $db t1 [list insert] false
          608  +  makeSomeChanges $db t1 [list insert]
   609    609   
   610    610     set connection [getDbConnection]
   611    611   
   612    612     set session [$connection -alias CreateSession main]
   613    613   
   614    614     $session -marshalflags +DynamicCallback \
   615    615         SetTableFilter tableFilterCallbackT1 null
   616    616   
   617         -  makeSomeChanges $db t2 [list insert] false
          617  +  makeSomeChanges $db t2 [list insert]
   618    618     lappend result IsEmpty [$session IsEmpty]
   619    619   
   620    620     lappend result MatchT2 [matchSession $connection $session {
   621    621       [$item TableName] eq "t2"
   622    622     }]
   623    623   
   624         -  makeSomeChanges $db t1 [list insert] false
          624  +  makeSomeChanges $db t1 [list insert]
   625    625     lappend result IsEmpty [$session IsEmpty]
   626    626   
   627    627     lappend result MatchT1 [matchSession $connection $session {
   628    628       [$item TableName] eq "t1"
   629    629     }]
   630    630   
   631    631     $session SetTableFilter null null
   632    632   
   633         -  makeSomeChanges $db t2 [list insert] false
          633  +  makeSomeChanges $db t2 [list insert]
   634    634     lappend result IsEmpty [$session IsEmpty]
   635    635   
   636    636     lappend result MatchT2 [matchSession $connection $session {
   637    637       [$item TableName] eq "t2"
   638    638     }]
   639    639   
   640         -  makeSomeChanges $db t1 [list insert] false
          640  +  makeSomeChanges $db t1 [list insert]
   641    641     lappend result IsEmpty [$session IsEmpty]
   642    642   
   643    643     lappend result MatchT1 [matchSession $connection $session {
   644    644       [$item TableName] eq "t1"
   645    645     }]
   646    646   
   647    647     set result
................................................................................
   675    675   
   676    676   runTest {test session-1.6 {combine and apply change sets} -setup {
   677    677     setupDb [set fileName session-1.6.db]
   678    678   
   679    679     cleanupSomeText
   680    680   } -body {
   681    681     createTheSchema $db main
   682         -  makeSomeChanges $db t1 [list insert insert] false
          682  +  makeSomeChanges $db t1 [list insert insert]
   683    683   
   684    684     set connection [getDbConnection]
   685    685   
   686    686     set rawData(1) [captureChangeSetRawData $connection main null {
   687         -    makeSomeChanges $db t1 [list delete] false 1
          687  +    makeSomeChanges $db t1 [list delete] 1
   688    688     }]; object removeref $rawData(1)
   689    689   
   690         -  makeSomeChanges $db t1 [list insert] false 1
          690  +  makeSomeChanges $db t1 [list insert] 1
   691    691   
   692    692     set rawData(2) [captureChangeSetRawData $connection main null {
   693         -    makeSomeChanges $db t1 [list insert] false
          693  +    makeSomeChanges $db t1 [list insert]
   694    694     }]; object removeref $rawData(2)
   695    695   
   696    696     set changeSet(1) [$connection -alias CreateChangeSet $rawData(1)]
   697    697     set changeSet(2) [$connection -alias CreateChangeSet $rawData(2)]
   698    698     set changeSet(3) [$changeSet(1) -alias CombineWith $changeSet(2)]
   699    699   
   700    700     $changeSet(3) -marshalflags +DynamicCallback Apply conflictCallback null
................................................................................
   739    739   
   740    740   runTest {test session-1.7 {differences between tables} -setup {
   741    741     setupDb [set fileName session-1.7.db]
   742    742   
   743    743     cleanupSomeText
   744    744   } -body {
   745    745     createTheSchema $db main
   746         -  makeSomeChanges $db t1 [list insert insert] false
          746  +  makeSomeChanges $db t1 [list insert insert]
   747    747   
   748    748     set result [list]
   749    749   
   750    750     lappend result [sql execute -execute reader -format list $db \
   751    751         {SELECT x, y FROM t1 ORDER BY x;}]
   752    752   
   753    753     createTheSchema $db temp
   754    754     sql execute $db {INSERT INTO temp.t1 SELECT * FROM main.t1;}
   755         -  makeSomeChanges $db temp.t1 [list insert insert] false
          755  +  makeSomeChanges $db temp.t1 [list insert insert]
   756    756   
   757    757     set connection [getDbConnection]
   758    758   
   759    759     set session [$connection -alias CreateSession main]
   760    760     $session AttachTable null
   761    761     $session LoadDifferencesFromTable temp t1
   762    762   
................................................................................
   777    777   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   778    778   System.Data.SQLite SQLiteInterop\
   779    779   defineConstant.System.Data.SQLite.INTEROP_SESSION_EXTENSION} -result {{1\
   780    780   {inserted: Alpha Bravo Charlie Delta Echo} 2 {inserted: Foxtrot Golf Hotel\
   781    781   India Juliet}} {1 {inserted: Alpha Bravo Charlie Delta Echo} 2 {inserted:\
   782    782   Foxtrot Golf Hotel India Juliet} 3 {inserted: Kilo Lima Mike November Oscar} 4\
   783    783   {inserted: Papa Quebec Romeo Sierra Tango}}}}
   784         -
   785         -###############################################################################
   786         -
   787         -
   788         -
   789         -
   790    784   
   791    785   ###############################################################################
   792    786   
   793    787   rename conflictCallback ""
   794    788   rename tableFilterCallbackT1 ""
   795    789   rename createByteArray ""
   796    790   rename arrayToList ""