Permalink
Browse files

Add a createTable function to the common test code.

  • Loading branch information...
1 parent a3db51b commit 2e80b78b3710fb1340d65007a0c7949e35b215db @orlandov committed Sep 29, 2010
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/lib/common.js
View
@@ -61,3 +61,21 @@ exports.getResultsStep = function (db, callback) {
doStep();
});
}
+
+exports.createTable = function (db, name, columns, callback) {
+ var columnFragment
+ = '(' +
+ columns.map(function (i) {
+ return i.name + " " + i.type
+ }).join(', ') +
+ ')';
+
+ db.prepare('CREATE TABLE ' + name + ' ' + columnFragment,
+ function (error, createStatement) {
+ if (error) throw error;
+ createStatement.step(function (error, row) {
+ if (error) throw error;
+ callback();
+ });
+ });
+}

0 comments on commit 2e80b78

Please sign in to comment.