Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an index so volt client can be imported using the module mechanisms #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
!(function(global) { // eslint-disable-line no-unused-vars

"use strict";

const VoltClient = require("./client");
const VoltConfiguration = require("./configuration");
const VoltConstants = require("./voltconstants");

/*
* AFAICT VoltQuery used to be exported from query.js but is deprecated and
* now query exports VoltProcedure which should be used instead.
*/
const VoltProcedure = require("./query");

module.exports = {
VoltClient : VoltClient,
VoltConfiguration : VoltConfiguration,
VoltConstants : VoltConstants,
VoltProcedure : VoltProcedure
};

})();
94 changes: 94 additions & 0 deletions test/cases/module-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
!(function(global) { // eslint-disable-line no-unused-vars

"use strict";

require("nodeunit");
const debug = require("debug")("voltdb-client-nodejs:ModuleTest");

// Exports
module.exports = {
setUp : function(callback) {
callback();
},
tearDown : function(callback) {
callback();
},
requireTest : function(test) {

/**
* Just test if the expected members are there and that they are in fact
* what they should be.
*/

debug("requireTest");

test.expect(18);

/*
* Module tests
*/
const voltdb = require("../../lib/");
test.notEqual(typeof voltdb.VoltClient, "undefined",
"VoltClient member not present");
test.equal(typeof voltdb.VoltClient, "function",
"VoltClient is present but not a function");

test.notEqual(typeof voltdb.VoltConfiguration, "undefined",
"VoltClient function not present");
test.equal(typeof voltdb.VoltConfiguration, "function",
"VoltConfiguration is present but not a function");

test.notEqual(typeof voltdb.VoltConstants, "undefined",
"VoltClient function not present");
test.equal(typeof voltdb.VoltConstants, "object",
"VoltConstants is present but not an object");

test.notEqual(typeof voltdb.VoltProcedure, "undefined",
"VoltClient function not present");
test.equal(typeof voltdb.VoltProcedure, "function",
"VoltProcedure is present but not a function");

/*
* VoltClient
*/
const voltClient = new voltdb.VoltClient();
test.notEqual(typeof voltClient.connect, "undefined",
"VoltClient.connect member not present");
test.equal(typeof voltClient.connect, "function",
"VoltClient.connect is present but not a function");

/*
* VoltConfiguration
*/
const voltConfiguration = new voltdb.VoltConfiguration();
test.notEqual(typeof voltConfiguration.host, "undefined",
"VoltConfiguration.host member not present");
test.equal(typeof voltConfiguration.host, "string",
"VoltConfiguration.host is present but not a string");

/*
* VoltConstants
*/
const voltConstants = voltdb.VoltConstants;
test.notEqual(typeof voltConstants.STATUS_CODES, "undefined",
"VoltConstants.STATUS_CODES member not present");
test.equal(typeof voltConstants.STATUS_CODES, "object",
"VoltConstants.STATUS_CODES is present but not an object");
test.notEqual(typeof voltConstants.STATUS_CODES.SUCCESS, "undefined",
"VoltConstants.STATUS_CODES.SUCCESS member not present");
test.equal(voltConstants.STATUS_CODES.SUCCESS, null,
"VoltConstants.STATUS_CODES.SUCCESS is present but not null");

/*
* VoltProcedure
*/
const voltProcedure = new voltdb.VoltProcedure();
test.notEqual(typeof voltProcedure.getQuery, "undefined",
"VoltProcedure.getQuery member not present");
test.equals(typeof voltProcedure.getQuery, "function",
"VoltProcedure.getQuery is present but not a function");

test.done();
}
};
})();