OLD | NEW |
(Empty) | |
| 1 # 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 # |
| 14 set testdir [file dirname $argv0] |
| 15 source $testdir/tester.tcl |
| 16 |
| 17 if {$tcl_platform(platform)=="windows"} { |
| 18 set PROG "sqldiff.exe" |
| 19 } else { |
| 20 set PROG "./sqldiff" |
| 21 } |
| 22 if {![file exe $PROG]} { |
| 23 puts "sqldiff cannot run because $PROG is not available" |
| 24 finish_test |
| 25 return |
| 26 } |
| 27 db close |
| 28 forcedelete test.db test2.db |
| 29 sqlite3 db test.db |
| 30 |
| 31 do_test sqldiff-1.0 { |
| 32 db eval { |
| 33 CREATE TABLE t1(a INTEGER PRIMARY KEY, b); |
| 34 CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID; |
| 35 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100) |
| 36 INSERT INTO t1(a,b) SELECT x, printf('abc-%d-xyz',x) FROM c; |
| 37 INSERT INTO t2(a,b) SELECT a, b FROM t1; |
| 38 } |
| 39 db backup test2.db |
| 40 db eval { |
| 41 ATTACH 'test2.db' AS x2; |
| 42 DELETE FROM x2.t1 WHERE a=49; |
| 43 DELETE FROM x2.t2 WHERE a=48; |
| 44 INSERT INTO x2.t1(a,b) VALUES(1234,'hello'); |
| 45 INSERT INTO x2.t2(a,b) VALUES(50.5,'xyzzy'); |
| 46 CREATE TABLE x2.t3(a,b,c); |
| 47 INSERT INTO x2.t3 VALUES(111,222,333); |
| 48 CREATE TABLE main.t4(x,y,z); |
| 49 INSERT INTO t4 SELECT * FROM t3; |
| 50 } |
| 51 set line "exec $PROG test.db test2.db" |
| 52 unset -nocomplain ::MSG |
| 53 catch {eval $line} ::MSG |
| 54 } {0} |
| 55 do_test sqldiff-1.1 { |
| 56 set ::MSG |
| 57 } {DELETE FROM t1 WHERE a=49; |
| 58 INSERT INTO t1(a,b) VALUES(1234,'hello'); |
| 59 DELETE FROM t2 WHERE a=48; |
| 60 INSERT INTO t2(a,b) VALUES(50.5,'xyzzy'); |
| 61 CREATE TABLE t3(a,b,c); |
| 62 INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333); |
| 63 DROP TABLE t4;} |
| 64 |
| 65 finish_test |
OLD | NEW |