sqlite/ext/ota/ota9.test

67 lines
1.5 KiB
Plaintext

# 2014 November 21
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Test OTA with virtual tables
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
set ::testprefix ota9
ifcapable !fts3 {
finish_test
return
}
do_execsql_test 1.1 {
CREATE VIRTUAL TABLE f1 USING fts4(a, b, c);
INSERT INTO f1(rowid, a, b, c) VALUES(11, 'a', 'b', 'c');
INSERT INTO f1(rowid, a, b, c) VALUES(12, 'd', 'e', 'f');
INSERT INTO f1(rowid, a, b, c) VALUES(13, 'g', 'h', 'i');
}
do_test 1.1 {
forcedelete ota.db
sqlite3 db2 ota.db
db2 eval {
CREATE TABLE data_f1(ota_rowid, a, b, c, ota_control);
INSERT INTO data_f1 VALUES(14, 'x', 'y', 'z', 0); -- INSERT
INSERT INTO data_f1 VALUES(11, NULL, NULL, NULL, 1); -- DELETE
INSERT INTO data_f1 VALUES(13, NULL, NULL, 'X', '..x'); -- UPDATE
}
db2 close
} {}
do_test 1.2.1 {
while 1 {
sqlite3ota ota test.db ota.db
set rc [ota step]
if {$rc != "SQLITE_OK"} break
ota close
}
ota close
} {SQLITE_DONE}
do_execsql_test 1.2.2 { SELECT rowid, * FROM f1 } {
12 d e f
13 g h X
14 x y z
}
do_execsql_test 1.2.3 { INSERT INTO f1(f1) VALUES('integrity-check') }
integrity_check 1.2.4
finish_test