# 2011 March 24 # # 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. # #*********************************************************************** # This file implements regression tests for the session module. # if {![info exists testdir]} { set testdir [file join [file dirname [info script]] .. .. test] } source [file join [file dirname [info script]] session_common.tcl] source $testdir/tester.tcl set testprefix session3 # These tests - session3-1.* - verify that the session module behaves # correctly when confronted with a schema mismatch when applying a # changeset (in function sqlite3changeset_apply()). # # session3-1.1.*: Table does not exist in target db. # session3-1.2.*: Table has wrong number of columns in target db. # session3-1.3.*: Table has wrong PK columns in target db. # db close sqlite3_shutdown test_sqlite3_log log sqlite3 db test.db proc log {code msg} { lappend ::log $code $msg } forcedelete test.db2 sqlite3 db2 test.db2 do_execsql_test 1.0 { CREATE TABLE t1(a PRIMARY KEY, b); } do_test 1.1 { set ::log {} do_then_apply_sql { INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(3, 4); } set ::log } {SQLITE_SCHEMA {sqlite3changeset_apply(): no such table: t1}} do_test 1.2.0 { execsql { CREATE TABLE t1(a PRIMARY KEY, b, c) } db2 } {} do_test 1.2.1 { set ::log {} do_then_apply_sql { INSERT INTO t1 VALUES(5, 6); INSERT INTO t1 VALUES(7, 8); } set ::log } {SQLITE_SCHEMA {sqlite3changeset_apply(): table t1 has 3 columns, expected 2}} do_test 1.3.0 { execsql { DROP TABLE t1; CREATE TABLE t1(a, b PRIMARY KEY); } db2 } {} do_test 1.3.1 { set ::log {} do_then_apply_sql { INSERT INTO t1 VALUES(9, 10); INSERT INTO t1 VALUES(11, 12); } set ::log } {SQLITE_SCHEMA {sqlite3changeset_apply(): primary key mismatch for table t1}} catch { db close } catch { db2 close } sqlite3_shutdown test_sqlite3_log sqlite3_initialize finish_test