Skip to content

Commit

Permalink
add test case for lastID, ref fritx/cross-sqlcipher#4
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Oct 4, 2017
1 parent 9913b45 commit 99a8722
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,30 @@ test.serial.cb('decrypt with wrong cipher', t => {
})
})
})

// https://github.com/fritx/cross-sqlcipher/issues/4
// https://github.com/mapbox/node-sqlite3/issues/622#issuecomment-212518985
test.serial.cb('has lastID', t => {
let db = new sqlite3.Database(dbFile)
t.plan(2)

db.serialize(() => {
db.run("PRAGMA KEY = 'secret'")
db.run("PRAGMA CIPHER = 'aes-256-cbc'")

db.run('INSERT INTO lorem VALUES (?)', 'test-lastID-1', function (err) {
if (err) return t.end(err)
t.is(this.lastID, 11)
})

let stmt = db.prepare('INSERT INTO lorem VALUES (?)')
stmt.run('test-lastID-2', err => {
if (err) return t.end(err)
t.is(stmt.lastID, 12)
})
})

db.close(() => {
t.end()
})
})

0 comments on commit 99a8722

Please sign in to comment.