blob: 4f4cd7082c72fa5c012a3544fdf0e1d9c49d0eb9 [file] [log] [blame]
drhd13b2312015-05-11 17:46:14 +00001# 2015-05-11
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11#
12# Quick tests for the sqldiff tool
13#
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16if {$tcl_platform(platform)=="windows"} {
17 set PROG "sqldiff.exe"
18} else {
19 set PROG "./sqldiff"
20}
21db close
22forcedelete test.db test2.db
23sqlite3 db test.db
24
25do_test sqldiff-1.0 {
26 db eval {
27 CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
28 CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID;
29 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
30 INSERT INTO t1(a,b) SELECT x, printf('abc-%d-xyz',x) FROM c;
31 INSERT INTO t2(a,b) SELECT a, b FROM t1;
32 }
33 db backup test2.db
34 db eval {
35 ATTACH 'test2.db' AS x2;
36 DELETE FROM x2.t1 WHERE a=49;
37 DELETE FROM x2.t2 WHERE a=48;
38 INSERT INTO x2.t1(a,b) VALUES(1234,'hello');
39 INSERT INTO x2.t2(a,b) VALUES(50.5,'xyzzy');
40 CREATE TABLE x2.t3(a,b,c);
41 INSERT INTO x2.t3 VALUES(111,222,333);
42 CREATE TABLE main.t4(x,y,z);
43 INSERT INTO t4 SELECT * FROM t3;
44 }
45 set line "exec $PROG test.db test2.db"
46 unset -nocomplain ::MSG
47 catch {eval $line} ::MSG
48} {0}
49do_test sqldiff-1.1 {
50 set ::MSG
51} {DELETE FROM t1 WHERE a=49;
52INSERT INTO t1(a,b) VALUES(1234,'hello');
53DELETE FROM t2 WHERE a=48;
54INSERT INTO t2(a,b) VALUES(50.5,'xyzzy');
55CREATE TABLE t3(a,b,c);
56INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333);
57DROP TABLE t4;}