Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | More work on tests. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sessions |
Files: | files | file ages | folders |
SHA1: |
a40c3117c68652ddabd5e0590a443082 |
User & Date: | mistachkin 2017-10-11 03:34:39.933 |
Context
2017-10-11
| ||
04:03 | Add test for the ISQLiteChangeSet.Invert method. check-in: 53b6aee403 user: mistachkin tags: sessions | |
03:34 | More work on tests. check-in: a40c3117c6 user: mistachkin tags: sessions | |
03:29 | Make sure that null is passed to the native sqlite3session_table_filter() API when the callback is null. Also, fix type signature of the session extension xFilter native delegate. check-in: f8d3d92453 user: mistachkin tags: sessions | |
Changes
Changes to Tests/session.eagle.
︙ | ︙ | |||
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | } return $result } ############################################################################### proc createTheSchema { db } { sql execute $db { CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT); } } ############################################################################### | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | } return $result } ############################################################################### proc matchSession { connection session expr } { if {[isObjectHandle $session] && $session ne "null"} then { if {![$session IsEmpty]} then { unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData return [matchChangeSet [set changeSet \ [$connection -alias CreateChangeSet $rawData]] $expr] } } return false } ############################################################################### proc matchChangeSet { changeSet expr } { if {[isObjectHandle $changeSet] && $changeSet ne "null"} then { object foreach -alias item $changeSet { if {[expr $expr]} then {return true} } } return false } ############################################################################### proc createTheSchema { db } { sql execute $db { CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT); CREATE TABLE t2(x INTEGER PRIMARY KEY, y TEXT); } } ############################################################################### proc makeSomeChanges { db table types random {count 5} } { foreach type $types { switch -nocase -- $type { insert { set text [appendArgs "inserted: " [getSomeText $random $count]] sql execute $db [subst { INSERT INTO ${table}(y) VALUES(?); }] [list param1 String $text] } update { set text [appendArgs "updated: " [getSomeText $random $count]] sql execute $db [subst { UPDATE ${table} SET y = ? WHERE x NOT IN ( (SELECT MIN(x) FROM ${table}), (SELECT MAX(x) FROM ${table}) ); }] [list param1 String $text] } delete { sql execute $db [subst { DELETE FROM ${table} WHERE x = (SELECT MIN(x) FROM ${table}); }] } } } } ############################################################################### |
︙ | ︙ | |||
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | } return $result } ############################################################################### runTest {test session-1.1 {basic session extension usage} -setup { setupDb [set fileName(0) session-1.1.db] set fileName(1) [getChangeSetFileName 1] set fileName(2) [getChangeSetFileName 2] cleanupSomeText } -body { createTheSchema $db | > > > > > > > > > | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | } return $result } ############################################################################### proc tableFilterCallbackT1 { clientData name } { lappend ::callbackResults [object invoke -create \ System.Boolean Parse [expr {[$name ToString] in [list t1]}]] return [lindex $::callbackResults end] } ############################################################################### runTest {test session-1.1 {basic session extension usage} -setup { setupDb [set fileName(0) session-1.1.db] set fileName(1) [getChangeSetFileName 1] set fileName(2) [getChangeSetFileName 2] cleanupSomeText } -body { createTheSchema $db makeSomeChanges $db t1 [list insert] true set connection [getDbConnection] set session [$connection -alias CreateSession main] $session AttachTable null makeSomeChanges $db t1 [list insert update delete] true unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData set stream(1) [object create -alias \ |
︙ | ︙ | |||
268 269 270 271 272 273 274 | runTest {test session-1.2 {session change set enumeration} -setup { setupDb [set fileName session-1.2.db] cleanupSomeText } -body { createTheSchema $db | | | < | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | runTest {test session-1.2 {session change set enumeration} -setup { setupDb [set fileName session-1.2.db] cleanupSomeText } -body { createTheSchema $db makeSomeChanges $db t1 [list insert insert insert] false set connection [getDbConnection] set session [$connection -alias CreateSession main] $session AttachTable null makeSomeChanges $db t1 [list insert update delete] false unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData set changeSet(1) [$connection -alias CreateChangeSet $rawData] changeSetToString $changeSet(1) true } -cleanup { cleanupSomeText unset -nocomplain changeSet rawData byteArray session freeDbConnection unset -nocomplain connection cleanupDb $fileName |
︙ | ︙ | |||
326 327 328 329 330 331 332 | runTest {test session-1.3 {session enabled/disabled state} -setup { setupDb [set fileName session-1.3.db] cleanupSomeText } -body { createTheSchema $db | | | | < | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | runTest {test session-1.3 {session enabled/disabled state} -setup { setupDb [set fileName session-1.3.db] cleanupSomeText } -body { createTheSchema $db makeSomeChanges $db t1 [list insert] false set connection [getDbConnection] set session [$connection -alias CreateSession main] lappend result IsEnabled [$session IsEnabled] $session AttachTable null lappend result IsEnabled [$session IsEnabled] $session SetToDisabled lappend result IsEnabled [$session IsEnabled] makeSomeChanges $db t1 [list insert] false lappend result IsEmpty [$session IsEmpty] unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData lappend result Length [$rawData Length] $session SetToEnabled lappend result IsEnabled [$session IsEnabled] makeSomeChanges $db t1 [list insert] false lappend result IsEmpty [$session IsEmpty] unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData set changeSet(1) [$connection -alias CreateChangeSet $rawData] lappend result [changeSetToString $changeSet(1) false] } -cleanup { cleanupSomeText unset -nocomplain result changeSet rawData byteArray session freeDbConnection unset -nocomplain connection cleanupDb $fileName |
︙ | ︙ | |||
390 391 392 393 394 395 396 | runTest {test session-1.4 {session direct/indirect state} -setup { setupDb [set fileName session-1.4.db] cleanupSomeText } -body { createTheSchema $db | | | | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | runTest {test session-1.4 {session direct/indirect state} -setup { setupDb [set fileName session-1.4.db] cleanupSomeText } -body { createTheSchema $db makeSomeChanges $db t1 [list insert] false set connection [getDbConnection] set session [$connection -alias CreateSession main] lappend result IsIndirect [$session IsIndirect] $session AttachTable null lappend result IsIndirect [$session IsIndirect] $session SetToIndirect lappend result IsIndirect [$session IsIndirect] makeSomeChanges $db t1 [list insert] false lappend result IsEmpty [$session IsEmpty] unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData $session SetToDirect lappend result IsIndirect [$session IsIndirect] makeSomeChanges $db t1 [list insert] false lappend result IsEmpty [$session IsEmpty] unset -nocomplain byteArray; set byteArray null $session -alias CreateChangeSet byteArray set rawData [createByteArray [arrayToList byteArray]] object removeref $rawData set changeSet(1) [$connection -alias CreateChangeSet $rawData] lappend result [changeSetToString $changeSet(1) false] } -cleanup { cleanupSomeText unset -nocomplain result changeSet rawData byteArray session freeDbConnection unset -nocomplain connection cleanupDb $fileName unset -nocomplain db fileName } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite SQLiteInterop\ defineConstant.System.Data.SQLite.INTEROP_SESSION_EXTENSION} -result \ {IsIndirect False IsIndirect False IsIndirect True IsEmpty False IsIndirect\ False IsEmpty False {TableName t1 NumberOfColumns 2 OperationCode Insert\ Indirect True PrimaryKeyColumns {[True, False]} TableName t1 NumberOfColumns 2\ OperationCode Insert Indirect False PrimaryKeyColumns {[True, False]}}}} ############################################################################### runTest {test session-1.5 {session table filter} -setup { setupDb [set fileName session-1.5.db] cleanupSomeText } -body { createTheSchema $db makeSomeChanges $db t1 [list insert] false set connection [getDbConnection] set session [$connection -alias CreateSession main] $session -marshalflags +DynamicCallback \ SetTableFilter tableFilterCallbackT1 null makeSomeChanges $db t2 [list insert] false lappend result IsEmpty [$session IsEmpty] lappend result MatchT2 [matchSession $connection $session { [$item TableName] eq "t2" }] makeSomeChanges $db t1 [list insert] false lappend result IsEmpty [$session IsEmpty] lappend result MatchT1 [matchSession $connection $session { [$item TableName] eq "t1" }] $session SetTableFilter null null makeSomeChanges $db t2 [list insert] false lappend result IsEmpty [$session IsEmpty] lappend result MatchT2 [matchSession $connection $session { [$item TableName] eq "t2" }] makeSomeChanges $db t1 [list insert] false lappend result IsEmpty [$session IsEmpty] lappend result MatchT1 [matchSession $connection $session { [$item TableName] eq "t1" }] set result } -cleanup { cleanupSomeText unset -nocomplain result session freeDbConnection unset -nocomplain connection cleanupDb $fileName catch {object removecallback tableFilterCallbackT1} catch { foreach callbackResult $callbackResults { catch {object dispose $callbackResult} } } unset -nocomplain callbackResult callbackResults db fileName } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite SQLiteInterop\ defineConstant.System.Data.SQLite.INTEROP_SESSION_EXTENSION} -result {IsEmpty\ True MatchT2 false IsEmpty False MatchT1 true IsEmpty False MatchT2 true\ IsEmpty False MatchT1 true}} ############################################################################### rename tableFilterCallbackT1 "" rename createByteArray "" rename arrayToList "" rename getChangeSetFileName "" rename makeSomeChanges "" rename createTheSchema "" rename matchChangeSet "" rename matchSession "" rename changeSetToString "" rename forDisplay "" rename cleanupSomeText "" rename getSomeText "" ############################################################################### runSQLiteTestEpilogue runTestEpilogue |