update changelog for 4.5.1 release
[sqlcipher.git] / ext / rbu / rbuA.test
blob642caca1960a7095a42ff320bd64eb8714b73983
1 # 2014 August 30
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #***********************************************************************
12 # This file contains tests for the RBU module. More specifically, it
13 # contains tests to ensure that it is an error to attempt to update
14 # a wal mode database via RBU.
17 if {![info exists testdir]} {
18   set testdir [file join [file dirname [info script]] .. .. test]
20 source $testdir/tester.tcl
21 set ::testprefix rbuA
23 set db_sql {
24   CREATE TABLE t1(a PRIMARY KEY, b, c);
26 set rbu_sql {
27   CREATE TABLE data_t1(a, b, c, rbu_control);
28   INSERT INTO data_t1 VALUES(1, 2, 3, 0);
29   INSERT INTO data_t1 VALUES(4, 5, 6, 0);
30   INSERT INTO data_t1 VALUES(7, 8, 9, 0);
33 do_test 1.0 {
34   db close
35   forcedelete test.db rbu.db
37   sqlite3 db test.db
38   db eval $db_sql
39   db eval { PRAGMA journal_mode = wal }
40   db close
42   sqlite3 db rbu.db
43   db eval $rbu_sql
44   db close
46   sqlite3rbu rbu test.db rbu.db
47   rbu step
48 } {SQLITE_ERROR}
49 do_test 1.1 {
50   list [catch { rbu close } msg] $msg
51 } {1 {SQLITE_ERROR - cannot update wal mode database}}
53 do_test 2.0 {
54   forcedelete test.db rbu.db
56   sqlite3 db test.db
57   db eval $db_sql
58   db close
60   sqlite3 db rbu.db
61   db eval $rbu_sql
62   db close
64   sqlite3rbu rbu test.db rbu.db
65   rbu step
66   rbu close
67 } {SQLITE_OK}
69 do_test 2.1 {
70   sqlite3 db test.db
71   db eval {PRAGMA journal_mode = wal}
72   db close
73   sqlite3rbu rbu test.db rbu.db
74   rbu step
75 } {SQLITE_ERROR}
77 do_test 2.2 {
78   list [catch { rbu close } msg] $msg
79 } {1 {SQLITE_ERROR - cannot update wal mode database}}
82 finish_test