blob: 723b7a5e13f24d379445666add1722f3ee1b8dda [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
drh6582ae52015-05-12 12:24:50 +000016
drhd13b2312015-05-11 17:46:14 +000017if {$tcl_platform(platform)=="windows"} {
18 set PROG "sqldiff.exe"
19} else {
20 set PROG "./sqldiff"
21}
22db close
23forcedelete test.db test2.db
24sqlite3 db test.db
25
26do_test sqldiff-1.0 {
27 db eval {
28 CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
29 CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID;
30 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
31 INSERT INTO t1(a,b) SELECT x, printf('abc-%d-xyz',x) FROM c;
32 INSERT INTO t2(a,b) SELECT a, b FROM t1;
33 }
34 db backup test2.db
35 db eval {
36 ATTACH 'test2.db' AS x2;
37 DELETE FROM x2.t1 WHERE a=49;
38 DELETE FROM x2.t2 WHERE a=48;
39 INSERT INTO x2.t1(a,b) VALUES(1234,'hello');
40 INSERT INTO x2.t2(a,b) VALUES(50.5,'xyzzy');
41 CREATE TABLE x2.t3(a,b,c);
42 INSERT INTO x2.t3 VALUES(111,222,333);
43 CREATE TABLE main.t4(x,y,z);
44 INSERT INTO t4 SELECT * FROM t3;
45 }
46 set line "exec $PROG test.db test2.db"
47 unset -nocomplain ::MSG
48 catch {eval $line} ::MSG
49} {0}
50do_test sqldiff-1.1 {
51 set ::MSG
52} {DELETE FROM t1 WHERE a=49;
53INSERT INTO t1(a,b) VALUES(1234,'hello');
54DELETE FROM t2 WHERE a=48;
55INSERT INTO t2(a,b) VALUES(50.5,'xyzzy');
56CREATE TABLE t3(a,b,c);
57INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333);
58DROP TABLE t4;}
drh8906b7d2015-05-11 18:48:52 +000059
60finish_test