sqlite/test/zipfile.test
dan 7c15ac1ada Update the zipfile module so that it matches the documentation.
FossilOrigin-Name: 7e7e472fa91a2bad2e521d4d67f176c8eb9edc1a07b283e425ea0fa2b6abba1f
2018-01-08 19:59:59 +00:00

84 lines
1.9 KiB
Plaintext

# 2017 December 9
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix zipfile
if {[catch {load_static_extension db zipfile} error]} {
puts "Skipping zipfile tests, hit load error: $error"
finish_test; return
}
forcedelete test.zip
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE temp.zz USING zipfile('test.zip');
PRAGMA table_info(zz);
} {
0 name {} 0 {} 0
1 mode {} 0 {} 0
2 mtime {} 0 {} 0
3 sz {} 0 {} 0
4 rawdata {} 0 {} 0
5 data {} 0 {} 0
6 method {} 0 {} 0
}
do_execsql_test 1.1.1 {
INSERT INTO zz(name, mode, mtime, sz, rawdata, method)
VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0);
}
do_execsql_test 1.1.2 {
INSERT INTO zz(name, mtime, sz, rawdata, method)
VALUES('g.txt', 1000000002, 5, '12345', 0);
}
do_execsql_test 1.2 {
SELECT name, mtime, data FROM zipfile('test.zip')
} {
f.txt 1000000000 abcde
g.txt 1000000002 12345
}
do_execsql_test 1.3 {
INSERT INTO zz(name, mode, mtime, data) VALUES('h.txt',
'-rw-r--r--', 1000000004, 'aaaaaaaaaabbbbbbbbbb'
);
}
do_execsql_test 1.4 {
SELECT name, mtime, data, method FROM zipfile('test.zip');
} {
f.txt 1000000000 abcde 0
g.txt 1000000002 12345 0
h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8
}
do_execsql_test 1.5.1 {
BEGIN;
INSERT INTO zz(name, mode, mtime, data, method)
VALUES('i.txt', '-rw-r--r--', 1000000006, 'zxcvb', 0);
SELECT name FROM zz;
COMMIT;
} {f.txt g.txt h.txt i.txt}
do_execsql_test 1.5.2 {
SELECT name FROM zz;
} {f.txt g.txt h.txt i.txt}
do_execsql_test 1.6.0 {
DELETE FROM zz WHERE name='g.txt';
SELECT name FROM zz;
} {f.txt h.txt i.txt}
finish_test