storage/test/unit/test_bug-444233.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/storage/test/unit/test_bug-444233.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function setup() {
     1.9 +    // Create the table
    1.10 +    getOpenedDatabase().createTable("test_bug444233",
    1.11 +                                    "id INTEGER PRIMARY KEY, value TEXT");
    1.12 +
    1.13 +    // Insert dummy data, using wrapper methods
    1.14 +    var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
    1.15 +    stmt.params.value = "value1"
    1.16 +    stmt.execute();
    1.17 +    stmt.finalize();
    1.18 +    
    1.19 +    stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
    1.20 +    stmt.params.value = "value2"
    1.21 +    stmt.execute();
    1.22 +    stmt.finalize();
    1.23 +}
    1.24 +
    1.25 +function test_bug444233() {
    1.26 +    print("*** test_bug444233: started");
    1.27 +    
    1.28 +    // Check that there are 2 results
    1.29 +    var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
    1.30 +    do_check_true(stmt.executeStep());
    1.31 +    do_check_eq(2, stmt.row.number);
    1.32 +    stmt.reset();
    1.33 +    stmt.finalize();
    1.34 +
    1.35 +    print("*** test_bug444233: doing delete");
    1.36 +    
    1.37 +    // Now try to delete using IN
    1.38 +    // Cheating since we know ids are 1,2
    1.39 +    try {
    1.40 +        var ids = [1, 2];
    1.41 +        stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
    1.42 +        stmt.params.ids = ids;
    1.43 +    } catch (e) {
    1.44 +        print("*** test_bug444233: successfully caught exception");
    1.45 +    }
    1.46 +    stmt.finalize();
    1.47 +}
    1.48 +
    1.49 +function run_test() {
    1.50 +    setup();
    1.51 +    test_bug444233();
    1.52 +    cleanup();
    1.53 +}
    1.54 +

mercurial