Enhance the command-line completion extension to return the names of
[sqlite.git] / ext / session / sessionE.test
blob9821dde816ab7b446931823bcfbca857ec497148
1 # 2015 June 02
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 implements regression tests for the sessions module.
13 # Specifically, it tests that operations on tables without primary keys
14 # are ignored.
19 if {![info exists testdir]} {
20   set testdir [file join [file dirname [info script]] .. .. test]
21
22 source [file join [file dirname [info script]] session_common.tcl]
23 source $testdir/tester.tcl
24 ifcapable !session {finish_test; return}
25 set testprefix sessionE
28 # Test plan:
30 #    1.*: Test that non-PK tables are not auto-attached.
31 #    2.*: Test that explicitly attaching a non-PK table is a no-op.
32 #    3.*: Test that sqlite3session_diff() on a non-PK table is a no-op.
36 #--------------------------------------------------------------------------
37 reset_db
38 do_execsql_test 1.0 {
39   CREATE TABLE t1(a, b);
40   CREATE TABLE t2(a PRIMARY KEY, b);
42 do_test 1.1 {
43   sqlite3session S db main
44   S attach *
45   execsql {
46     INSERT INTO t1 VALUES(1, 2);
47     INSERT INTO t2 VALUES(1, 2);
48   }
49 } {}
50 do_changeset_test 1.2 S {
51   {INSERT t2 0 X. {} {i 1 i 2}}
53 S delete
55 reset_db
56 do_execsql_test 2.0 {
57   CREATE TABLE t1(a, b);
58   CREATE TABLE t2(a PRIMARY KEY, b);
60 do_test 2.1 {
61   sqlite3session S db main
62   S attach t1
63   S attach t2
64   execsql {
65     INSERT INTO t1 VALUES(3, 4);
66     INSERT INTO t2 VALUES(3, 4);
67     INSERT INTO t1 VALUES(5, 6);
68     INSERT INTO t2 VALUES(5, 6);
69   }
70 } {}
71 do_changeset_test 2.2 S {
72   {INSERT t2 0 X. {} {i 3 i 4}}
73   {INSERT t2 0 X. {} {i 5 i 6}}
75 S delete
77 reset_db
78 forcedelete test.db2
79 do_execsql_test 3.0 {
80   ATTACH 'test.db2' AS aux;
81   CREATE TABLE aux.t1(a, b);
82   CREATE TABLE aux.t2(a PRIMARY KEY, b);
84   CREATE TABLE t1(a, b);
85   CREATE TABLE t2(a PRIMARY KEY, b);
87   INSERT INTO t1 VALUES(1, 2);
88   INSERT INTO t2 VALUES(3, 4);
90 do_test 3.1 {
91   sqlite3session S db main
92   S attach t1
93   S diff aux t1
95   S attach t2
96   S diff aux t2
97 } {}
98 do_changeset_test 3.2 S {
99   {INSERT t2 0 X. {} {i 3 i 4}}
101 do_execsql_test 3.3 {
102   INSERT INTO t1 VALUES(5, 6);
103   INSERT INTO t2 VALUES(7, 8);
105 do_changeset_test 3.4 S {
106   {INSERT t2 0 X. {} {i 3 i 4}}
107   {INSERT t2 0 X. {} {i 7 i 8}}
111 S delete
113 finish_test