#98: Replace nodeunit by mocha
This commit is contained in:
Родитель
26fcf41a2c
Коммит
237f7d8982
|
@ -85,8 +85,8 @@ BlockListResult.parse = function (blockListXml) {
|
|||
blockListResult.UncommittedBlocks = blockListXml.UncommittedBlocks.Block;
|
||||
}
|
||||
|
||||
if (blockListXml.LatestBlocks && blockListXml.Latest.Block && blockListXml.Latest.Block.length > 0) {
|
||||
blockListResult.LatestBlocks = blockListXml.Latest.Block;
|
||||
if (blockListXml.LatestBlocks && blockListXml.Laassert.Block && blockListXml.Laassert.Block.length > 0) {
|
||||
blockListResult.LatestBlocks = blockListXml.Laassert.Block;
|
||||
}
|
||||
|
||||
return blockListResult;
|
||||
|
|
|
@ -410,7 +410,7 @@ var Constants = {
|
|||
LAST_MODIFIED_ELEMENT: 'Last-Modified',
|
||||
|
||||
/**
|
||||
* XML element for the latest.
|
||||
* XML element for the laassert.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
|
|
|
@ -91,7 +91,7 @@ exports.stringFormat = function (text) {
|
|||
/**
|
||||
* Determines if a string starts with another.
|
||||
*
|
||||
* @param {string} text The string to test.
|
||||
* @param {string} text The string to assert.
|
||||
* @param {string} prefix The string prefix.
|
||||
* @return {Bool} True if the string starts with the prefix; false otherwise.
|
||||
*/
|
||||
|
@ -102,7 +102,7 @@ exports.stringStartsWith = function (text, prefix) {
|
|||
/**
|
||||
* Determines if a string ends with another.
|
||||
*
|
||||
* @param {string} text The string to test.
|
||||
* @param {string} text The string to assert.
|
||||
* @param {string} suffix The string suffix.
|
||||
* @return {Bool} True if the string ends with the suffix; false otherwise.
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ exports.stringEndsWith = function (text, suffix) {
|
|||
/**
|
||||
* Determines if a string contains an integer number.
|
||||
*
|
||||
* @param {string} text The string to test.
|
||||
* @param {string} text The string to assert.
|
||||
* @return {Bool} True if the string contains an integer number; false otherwise.
|
||||
*/
|
||||
exports.stringIsInt = function (value) {
|
||||
|
@ -129,7 +129,7 @@ exports.stringIsInt = function (value) {
|
|||
/**
|
||||
* Determines if a string contains a float number.
|
||||
*
|
||||
* @param {string} text The string to test.
|
||||
* @param {string} text The string to assert.
|
||||
* @return {Bool} True if the string contains a float number; false otherwise.
|
||||
*/
|
||||
exports.stringIsFloat = function(value) {
|
||||
|
@ -145,7 +145,7 @@ exports.stringIsFloat = function(value) {
|
|||
/**
|
||||
* Determines if a string contains a number.
|
||||
*
|
||||
* @param {string} text The string to test.
|
||||
* @param {string} text The string to assert.
|
||||
* @return {Bool} True if the string contains a number; false otherwise.
|
||||
*/
|
||||
exports.stringIsNumber = function(value) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"underscore.string": ">= 2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodeunit": ">= 0.6.4"
|
||||
"mocha": "*"
|
||||
},
|
||||
"homepage": "http://github.com/WindowsAzure/azure-sdk-for-node",
|
||||
"repository": {
|
||||
|
|
|
@ -249,9 +249,6 @@
|
|||
<Content Include="..\..\lib\util\atomhandler.js">
|
||||
<Link>lib\util\atomhandler.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\lib\util\base64.js">
|
||||
<Link>lib\util\base64.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\lib\util\constants.js">
|
||||
<Link>lib\util\constants.js</Link>
|
||||
</Content>
|
||||
|
@ -363,9 +360,6 @@
|
|||
<Content Include="..\..\test\util\atomhandler-tests.js">
|
||||
<Link>test\util\atomhandler-tests.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\test\util\base64-tests.js">
|
||||
<Link>test\util\base64-tests.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\test\util\blob-test-utils.js">
|
||||
<Link>test\util\blob-test-utils.js</Link>
|
||||
</Content>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../lib/azure');
|
||||
|
||||
|
@ -38,9 +38,8 @@ var originalServiceBusIssuer = null;
|
|||
var originalServiceBusAccessKey = null;
|
||||
var originalWrapNamespace = null;
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('azure', function () {
|
||||
setup(function (done) {
|
||||
if (firstRun) {
|
||||
firstRun = false;
|
||||
|
||||
|
@ -71,10 +70,10 @@ module.exports = testCase(
|
|||
}
|
||||
}
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown(function (done) {
|
||||
// Make sure emulated is never a left over after the test runs.
|
||||
delete process.env[ServiceClient.EnvironmentVariables.EMULATED];
|
||||
|
||||
|
@ -103,48 +102,51 @@ module.exports = testCase(
|
|||
}
|
||||
|
||||
// clean up
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testExponentialRetryPolicyFilter: function (test) {
|
||||
test.notEqual(azure.ExponentialRetryPolicyFilter, null);
|
||||
test.done();
|
||||
},
|
||||
test('ExponentialRetryPolicyFilter', function (done) {
|
||||
assert.notEqual(azure.ExponentialRetryPolicyFilter, null);
|
||||
|
||||
testLinearRetryPolicyFilter: function (test) {
|
||||
test.notEqual(azure.LinearRetryPolicyFilter, null);
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testConstants: function (test) {
|
||||
test.notEqual(azure.Constants, null);
|
||||
test.done();
|
||||
},
|
||||
test('LinearRetryPolicyFilter', function (done) {
|
||||
assert.notEqual(azure.LinearRetryPolicyFilter, null);
|
||||
|
||||
testIsEmulated: function (test) {
|
||||
done();
|
||||
});
|
||||
|
||||
test('Constants', function (done) {
|
||||
assert.notEqual(azure.Constants, null);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('IsEmulated', function (done) {
|
||||
var ServiceClient = azure.ServiceClient;
|
||||
delete process.env[ServiceClient.EnvironmentVariables.EMULATED];
|
||||
test.equal(azure.isEmulated(), false);
|
||||
assert.equal(azure.isEmulated(), false);
|
||||
|
||||
// set some environment credentials for the live windows azure services
|
||||
process.env[ServiceClient.EnvironmentVariables.AZURE_STORAGE_ACCOUNT] = environmentAzureStorageAccount;
|
||||
process.env[ServiceClient.EnvironmentVariables.AZURE_STORAGE_ACCESS_KEY] = environmentAzureStorageAccessKey;
|
||||
|
||||
var blobService1 = azure.createBlobService();
|
||||
test.equal(blobService1.host, ServiceClient.CLOUD_BLOB_HOST);
|
||||
test.equal(blobService1.usePathStyleUri, false);
|
||||
assert.equal(blobService1.host, ServiceClient.CLOUD_BLOB_HOST);
|
||||
assert.equal(blobService1.usePathStyleUri, false);
|
||||
|
||||
process.env[ServiceClient.EnvironmentVariables.EMULATED] = true;
|
||||
test.equal(azure.isEmulated(), true);
|
||||
assert.equal(azure.isEmulated(), true);
|
||||
|
||||
var blobService2 = azure.createBlobService();
|
||||
test.equal(blobService2.host, '127.0.0.1');
|
||||
test.equal(blobService2.usePathStyleUri, true);
|
||||
assert.equal(blobService2.host, '127.0.0.1');
|
||||
assert.equal(blobService2.usePathStyleUri, true);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testNotEmulatedExplicitCredentials: function (test) {
|
||||
test('NotEmulatedExplicitCredentials', function (done) {
|
||||
// Make sure is not emulated
|
||||
delete process.env[ServiceClient.EnvironmentVariables.EMULATED];
|
||||
|
||||
|
@ -156,17 +158,17 @@ module.exports = testCase(
|
|||
var blobService = azure.createBlobService(parameterAzureStorageAccount, parameterAzureStorageAccessKey);
|
||||
|
||||
// Points to the live services
|
||||
test.equal(blobService.usePathStyleUri, false);
|
||||
test.equal(blobService.host, ServiceClient.CLOUD_BLOB_HOST);
|
||||
assert.equal(blobService.usePathStyleUri, false);
|
||||
assert.equal(blobService.host, ServiceClient.CLOUD_BLOB_HOST);
|
||||
|
||||
// And credentials are the ones passed
|
||||
test.equal(blobService.authenticationProvider.storageAccount, parameterAzureStorageAccount);
|
||||
test.equal(blobService.authenticationProvider.storageAccessKey, parameterAzureStorageAccessKey);
|
||||
assert.equal(blobService.authenticationProvider.storageAccount, parameterAzureStorageAccount);
|
||||
assert.equal(blobService.authenticationProvider.storageAccessKey, parameterAzureStorageAccessKey);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testEmulatedExplicitCredentials: function (test) {
|
||||
test('EmulatedExplicitCredentials', function (done) {
|
||||
// set emulated to true
|
||||
process.env[ServiceClient.EnvironmentVariables.EMULATED] = true;
|
||||
|
||||
|
@ -178,17 +180,17 @@ module.exports = testCase(
|
|||
var blobService = azure.createBlobService(parameterAzureStorageAccount, parameterAzureStorageAccessKey);
|
||||
|
||||
// Points to the emulator
|
||||
test.equal(blobService.usePathStyleUri, true);
|
||||
test.equal(blobService.host + ':' + blobService.port, ServiceClient.DEVSTORE_BLOB_HOST);
|
||||
assert.equal(blobService.usePathStyleUri, true);
|
||||
assert.equal(blobService.host + ':' + blobService.port, ServiceClient.DEVSTORE_BLOB_HOST);
|
||||
|
||||
// But the used credentials are the ones passed because we were explicit
|
||||
test.equal(blobService.authenticationProvider.storageAccount, parameterAzureStorageAccount);
|
||||
test.equal(blobService.authenticationProvider.storageAccessKey, parameterAzureStorageAccessKey);
|
||||
assert.equal(blobService.authenticationProvider.storageAccount, parameterAzureStorageAccount);
|
||||
assert.equal(blobService.authenticationProvider.storageAccessKey, parameterAzureStorageAccessKey);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testEmulatedWithoutParameters: function (test) {
|
||||
test('EmulatedWithoutParameters', function (done) {
|
||||
// set emulated to true
|
||||
process.env[ServiceClient.EnvironmentVariables.EMULATED] = true;
|
||||
|
||||
|
@ -200,17 +202,17 @@ module.exports = testCase(
|
|||
var blobService = azure.createBlobService();
|
||||
|
||||
// Points to the emulator
|
||||
test.equal(blobService.usePathStyleUri, true);
|
||||
test.equal(blobService.host + ':' + blobService.port, ServiceClient.DEVSTORE_BLOB_HOST);
|
||||
assert.equal(blobService.usePathStyleUri, true);
|
||||
assert.equal(blobService.host + ':' + blobService.port, ServiceClient.DEVSTORE_BLOB_HOST);
|
||||
|
||||
// And uses the emulator credentials
|
||||
test.equal(blobService.authenticationProvider.storageAccount, ServiceClient.DEVSTORE_STORAGE_ACCOUNT);
|
||||
test.equal(blobService.authenticationProvider.storageAccessKey, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
assert.equal(blobService.authenticationProvider.storageAccount, ServiceClient.DEVSTORE_STORAGE_ACCOUNT);
|
||||
assert.equal(blobService.authenticationProvider.storageAccessKey, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testNotEmulatedWithoutParameters: function (test) {
|
||||
test('NotEmulatedWithoutParameters', function (done) {
|
||||
// Make sure is not emulated
|
||||
delete process.env[ServiceClient.EnvironmentVariables.EMULATED];
|
||||
|
||||
|
@ -222,17 +224,17 @@ module.exports = testCase(
|
|||
var blobService = azure.createBlobService();
|
||||
|
||||
// Points to the live service
|
||||
test.equal(blobService.usePathStyleUri, false);
|
||||
test.equal(blobService.host, ServiceClient.CLOUD_BLOB_HOST);
|
||||
assert.equal(blobService.usePathStyleUri, false);
|
||||
assert.equal(blobService.host, ServiceClient.CLOUD_BLOB_HOST);
|
||||
|
||||
// and uses the environment variables
|
||||
test.equal(blobService.authenticationProvider.storageAccount, environmentAzureStorageAccount);
|
||||
test.equal(blobService.authenticationProvider.storageAccessKey, environmentAzureStorageAccessKey);
|
||||
assert.equal(blobService.authenticationProvider.storageAccount, environmentAzureStorageAccount);
|
||||
assert.equal(blobService.authenticationProvider.storageAccessKey, environmentAzureStorageAccessKey);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testMissingServiceBusIssuerAndWrapNamespace: function (test) {
|
||||
test('MissingServiceBusIssuerAndWrapNamespace', function (done) {
|
||||
delete process.env[ServiceClient.EnvironmentVariables.AZURE_WRAP_NAMESPACE];
|
||||
delete process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_ISSUER];
|
||||
|
||||
|
@ -243,13 +245,13 @@ module.exports = testCase(
|
|||
var serviceBusService = azure.createServiceBusService();
|
||||
|
||||
// set correctly
|
||||
test.equal(serviceBusService.namespace, environmentServiceBusNamespace);
|
||||
test.equal(serviceBusService.accessKey, environmentServiceBusAccessKey);
|
||||
assert.equal(serviceBusService.namespace, environmentServiceBusNamespace);
|
||||
assert.equal(serviceBusService.accessKey, environmentServiceBusAccessKey);
|
||||
|
||||
// defaulted correctly
|
||||
test.equal(serviceBusService.acsNamespace, environmentServiceBusNamespace + ServiceClient.DEFAULT_WRAP_NAMESPACE_SUFFIX);
|
||||
test.equal(serviceBusService.issuer, ServiceClient.DEFAULT_SERVICEBUS_ISSUER);
|
||||
assert.equal(serviceBusService.acsNamespace, environmentServiceBusNamespace + ServiceClient.DEFAULT_WRAP_NAMESPACE_SUFFIX);
|
||||
assert.equal(serviceBusService.issuer, ServiceClient.DEFAULT_SERVICEBUS_ISSUER);
|
||||
|
||||
test.done();
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require("../../lib/azure");
|
||||
|
||||
|
@ -32,21 +32,20 @@ var tablePrefix = 'expretry';
|
|||
|
||||
var testPrefix = 'exponentialretrypolicyfilter-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('exponentialretrypolicyfilter-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
exponentialRetryPolicyFilter = new ExponentialRetryPolicyFilter();
|
||||
tableService = newTableService.withFilter(exponentialRetryPolicyFilter);
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
testRetryFailSingle: function (test) {
|
||||
test('RetryFailSingle', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
var retryCount = 3;
|
||||
|
@ -56,19 +55,19 @@ module.exports = testCase(
|
|||
exponentialRetryPolicyFilter.retryInterval = retryInterval;
|
||||
|
||||
tableService.createTable(tableName, function (err) {
|
||||
test.equal(err, null);
|
||||
assert.equal(err, null);
|
||||
|
||||
tableService.createTable(tableName, function (err2) {
|
||||
test.notEqual(err2, null);
|
||||
test.equal(err2.code, Constants.TableErrorCodeStrings.TABLE_ALREADY_EXISTS);
|
||||
test.equal(err2.innerError, null);
|
||||
assert.notEqual(err2, null);
|
||||
assert.equal(err2.code, Constants.TableErrorCodeStrings.TABLE_ALREADY_EXISTS);
|
||||
assert.equal(err2.innerError, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testRetryFailMultiple: function (test) {
|
||||
test('RetryFailMultiple', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
var retryCount = 3;
|
||||
|
@ -95,23 +94,23 @@ module.exports = testCase(
|
|||
};
|
||||
|
||||
tableService.createTable(tableName, function (err) {
|
||||
test.equal(err, null);
|
||||
assert.equal(err, null);
|
||||
|
||||
tableService.deleteTable(tableName, function (err2) {
|
||||
test.equal(err2, null);
|
||||
assert.equal(err2, null);
|
||||
|
||||
// trying to create a table right after a delete should force retry to kick in
|
||||
// table should be created nicely
|
||||
tableService.createTable(tableName, function (err3) {
|
||||
test.equal(err3, null);
|
||||
assert.equal(err3, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testGetTablePassOnGetTable: function (test) {
|
||||
test('GetTablePassOnGetTable', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
var retryCount = 3;
|
||||
|
@ -121,10 +120,10 @@ module.exports = testCase(
|
|||
exponentialRetryPolicyFilter.retryInterval = retryInterval;
|
||||
|
||||
tableService.getTable(tableName, function (err, table) {
|
||||
test.equal(err.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
test.equal(table, null);
|
||||
assert.equal(err.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
assert.equal(table, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require("../../lib/azure");
|
||||
|
||||
|
@ -32,21 +32,20 @@ var tablePrefix = 'linearretry';
|
|||
|
||||
var testPrefix = 'linearretrypolicyfilter-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('linearretrypolicyfilter-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
linearRetryPolicyFilter = new LinearRetryPolicyFilter();
|
||||
tableService = newTableService.withFilter(linearRetryPolicyFilter);
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
testRetryFailSingle: function (test) {
|
||||
test('RetryFailSingle', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
var retryCount = 3;
|
||||
|
@ -56,19 +55,19 @@ module.exports = testCase(
|
|||
linearRetryPolicyFilter.retryInterval = retryInterval;
|
||||
|
||||
tableService.createTable(tableName, function (err) {
|
||||
test.equal(err, null);
|
||||
assert.equal(err, null);
|
||||
|
||||
tableService.createTable(tableName, function (err2) {
|
||||
test.notEqual(err2, null);
|
||||
test.equal(err2.code, Constants.TableErrorCodeStrings.TABLE_ALREADY_EXISTS);
|
||||
test.equal(err2.innerError, null);
|
||||
assert.notEqual(err2, null);
|
||||
assert.equal(err2.code, Constants.TableErrorCodeStrings.TABLE_ALREADY_EXISTS);
|
||||
assert.equal(err2.innerError, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testRetryFailMultiple: function (test) {
|
||||
test('RetryFailMultiple', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
var retryCount = 3;
|
||||
|
@ -93,23 +92,23 @@ module.exports = testCase(
|
|||
};
|
||||
|
||||
tableService.createTable(tableName, function (err) {
|
||||
test.equal(err, null);
|
||||
assert.equal(err, null);
|
||||
|
||||
tableService.deleteTable(tableName, function (err2) {
|
||||
test.equal(err2, null);
|
||||
assert.equal(err2, null);
|
||||
|
||||
// trying to create a table right after a delete should force retry to kick in
|
||||
// table should be created nicely
|
||||
tableService.createTable(tableName, function (err3) {
|
||||
test.equal(err3, null);
|
||||
assert.equal(err3, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testRetryPassOnGetTable: function (test) {
|
||||
test('RetryPassOnGetTable', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
var retryCount = 3;
|
||||
|
@ -119,10 +118,10 @@ module.exports = testCase(
|
|||
linearRetryPolicyFilter.retryInterval = retryInterval;
|
||||
|
||||
tableService.getTable(tableName, function (err, table) {
|
||||
test.equal(err.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
test.equal(table, null);
|
||||
assert.equal(err.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
assert.equal(table, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
|
@ -18,7 +18,6 @@ services/table/tablequery-tests.js
|
|||
services/table/tableservice-batch-tests.js
|
||||
services/table/tableservice-tablequery-tests.js
|
||||
services/table/tableservice-tests.js
|
||||
util/base64-tests.js
|
||||
util/iso8061date-tests.js
|
||||
util/util-tests.js
|
||||
azure-tests.js
|
|
@ -13,8 +13,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Based on bin/nodeunit.js from the nodeunit module.
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
|
@ -30,6 +28,13 @@ if (path.existsSync('./extendedtestlist.txt')) {
|
|||
var files = fileContent.split('\n');
|
||||
|
||||
var args = (process.ARGV || process.argv);
|
||||
args.push('-u');
|
||||
args.push('tdd');
|
||||
|
||||
// TODO: remove this timeout once tests are faster
|
||||
args.push('-t');
|
||||
args.push('200000');
|
||||
|
||||
files.forEach(function (file) {
|
||||
// trim trailing \r if it exists
|
||||
file = file.replace('\r', '');
|
||||
|
@ -41,4 +46,4 @@ files.forEach(function (file) {
|
|||
}
|
||||
});
|
||||
|
||||
var nodebin = require('../node_modules/nodeunit/bin/nodeunit');
|
||||
require('../node_modules/mocha/bin/mocha');
|
|
@ -13,8 +13,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Based on bin/nodeunit.js from the nodeunit module.
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
|
@ -30,6 +28,13 @@ if (path.existsSync('./testlist.txt')) {
|
|||
var files = fileContent.split('\n');
|
||||
|
||||
var args = (process.ARGV || process.argv);
|
||||
args.push('-u');
|
||||
args.push('tdd');
|
||||
|
||||
// TODO: remove this timeout once tests are faster
|
||||
args.push('-t');
|
||||
args.push('200000');
|
||||
|
||||
files.forEach(function (file) {
|
||||
// trim trailing \r if it exists
|
||||
file = file.replace('\r', '');
|
||||
|
@ -41,4 +46,4 @@ files.forEach(function (file) {
|
|||
}
|
||||
});
|
||||
|
||||
require('../node_modules/nodeunit/bin/nodeunit');
|
||||
require('../node_modules/mocha/bin/mocha');
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require("path");
|
||||
var util = require('util');
|
||||
|
@ -38,15 +39,14 @@ var blobNamesPrefix = 'blob';
|
|||
var mockServerClient;
|
||||
var currentTestName;
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('blobservice-longrunning-tests', function () {
|
||||
setup: function (done) {
|
||||
blobService = azure.createBlobService(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY, ServiceClient.DEVSTORE_BLOB_HOST);
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown: function (done) {
|
||||
var deleteFiles = function () {
|
||||
// delete test files
|
||||
var list = fs.readdirSync('./');
|
||||
|
@ -56,7 +56,7 @@ module.exports = testCase(
|
|||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
done();
|
||||
};
|
||||
|
||||
// delete blob containers
|
||||
|
@ -78,37 +78,37 @@ module.exports = testCase(
|
|||
deleteFiles();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testGetBlobToStream: function (test) {
|
||||
test('GetBlobToStream', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames);
|
||||
var blobName = testutil.generateId(blobNamesPrefix, blobNames);
|
||||
var fileNameTarget = testutil.generateId('getBlobFile') + '.test';
|
||||
var blobText = 'Hello World';
|
||||
|
||||
blobService.createContainer(containerName, function (createError1, container1) {
|
||||
test.equal(createError1, null);
|
||||
test.notEqual(container1, null);
|
||||
assert.equal(createError1, null);
|
||||
assert.notEqual(container1, null);
|
||||
|
||||
blobService.createBlockBlobFromText(containerName, blobName, blobText, function (error1) {
|
||||
test.equal(error1, null);
|
||||
assert.equal(error1, null);
|
||||
|
||||
blobService.getBlobToFile(containerName, blobName, fileNameTarget, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
path.exists(fileNameTarget, function (exists) {
|
||||
test.equal(exists, true);
|
||||
assert.equal(exists, true);
|
||||
|
||||
var fileText = fs.readFileSync(fileNameTarget);
|
||||
test.equal(blobText, fileText);
|
||||
test.done();
|
||||
assert.equal(blobText, fileText);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSmallUploadBlobFromFile: function (test) {
|
||||
test('SmallUploadBlobFromFile', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames);
|
||||
var blobName = testutil.generateId(blobNamesPrefix, blobNames);
|
||||
var fileNameSource = testutil.generateId('getBlobFile') + '.test';
|
||||
|
@ -116,37 +116,37 @@ module.exports = testCase(
|
|||
|
||||
fs.writeFile(fileNameSource, blobText, function () {
|
||||
blobService.createContainer(containerName, function (createError1, container1, createResponse1) {
|
||||
test.equal(createError1, null);
|
||||
test.notEqual(container1, null);
|
||||
test.ok(createResponse1.isSuccessful);
|
||||
test.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError1, null);
|
||||
assert.notEqual(container1, null);
|
||||
assert.ok(createResponse1.isSuccessful);
|
||||
assert.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var blobOptions = { contentType: 'text' };
|
||||
blobService.createBlockBlobFromFile(containerName, blobName, fileNameSource, blobOptions, function (uploadError, blobResponse, uploadResponse) {
|
||||
test.equal(uploadError, null);
|
||||
test.notEqual(blobResponse, null);
|
||||
test.ok(uploadResponse.isSuccessful);
|
||||
assert.equal(uploadError, null);
|
||||
assert.notEqual(blobResponse, null);
|
||||
assert.ok(uploadResponse.isSuccessful);
|
||||
|
||||
blobService.getBlobToText(containerName, blobName, function (downloadErr, blobTextResponse) {
|
||||
test.equal(downloadErr, null);
|
||||
test.equal(blobTextResponse, blobText);
|
||||
assert.equal(downloadErr, null);
|
||||
assert.equal(blobTextResponse, blobText);
|
||||
|
||||
blobService.getBlobProperties(containerName, blobName, function (getBlobPropertiesErr, blobGetResponse) {
|
||||
test.equal(getBlobPropertiesErr, null);
|
||||
test.notEqual(blobGetResponse, null);
|
||||
assert.equal(getBlobPropertiesErr, null);
|
||||
assert.notEqual(blobGetResponse, null);
|
||||
if (blobGetResponse) {
|
||||
test.equal(blobOptions.contentType, blobGetResponse.contentType);
|
||||
assert.equal(blobOptions.contentType, blobGetResponse.contentType);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testAnalyzeStream: function (test) {
|
||||
test('AnalyzeStream', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames);
|
||||
var blobName = testutil.generateId(blobNamesPrefix, blobNames);
|
||||
var fileNameSource = testutil.generateId('getBlobFile') + '.test';
|
||||
|
@ -154,28 +154,28 @@ module.exports = testCase(
|
|||
|
||||
fs.writeFile(fileNameSource, blobText, function () {
|
||||
blobService.createContainer(containerName, function (createError1, container1, createResponse1) {
|
||||
test.equal(createError1, null);
|
||||
test.notEqual(container1, null);
|
||||
test.ok(createResponse1.isSuccessful);
|
||||
test.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError1, null);
|
||||
assert.notEqual(container1, null);
|
||||
assert.ok(createResponse1.isSuccessful);
|
||||
assert.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
blobService.createBlockBlobFromFile(containerName, blobName, fileNameSource, { setBlobContentMD5: true }, function (uploadError, blobResponse, uploadResponse) {
|
||||
test.equal(uploadError, null);
|
||||
test.notEqual(blobResponse, null);
|
||||
test.ok(uploadResponse.isSuccessful);
|
||||
assert.equal(uploadError, null);
|
||||
assert.notEqual(blobResponse, null);
|
||||
assert.ok(uploadResponse.isSuccessful);
|
||||
|
||||
blobService.getBlobToText(containerName, blobName, function (downloadErr, blobTextResponse) {
|
||||
test.equal(downloadErr, null);
|
||||
test.equal(blobTextResponse, blobText);
|
||||
assert.equal(downloadErr, null);
|
||||
assert.equal(blobTextResponse, blobText);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testInvalidMD5SmallFile: function (test) {
|
||||
test('InvalidMD5SmallFile', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames);
|
||||
var blobName = testutil.generateId(blobNamesPrefix, blobNames);
|
||||
var fileNames = [];
|
||||
|
@ -185,39 +185,39 @@ module.exports = testCase(
|
|||
|
||||
fs.writeFile(fileNameSource, blobText, function () {
|
||||
blobService.createContainer(containerName, function (createError1, container1, createResponse1) {
|
||||
test.equal(createError1, null);
|
||||
test.notEqual(container1, null);
|
||||
test.ok(createResponse1.isSuccessful);
|
||||
test.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError1, null);
|
||||
assert.notEqual(container1, null);
|
||||
assert.ok(createResponse1.isSuccessful);
|
||||
assert.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
blobService.createBlockBlobFromFile(containerName, blobName, fileNameSource, { setBlobContentMD5: true }, function (uploadError, blobResponse, uploadResponse) {
|
||||
test.equal(uploadError, null);
|
||||
test.notEqual(blobResponse, null);
|
||||
test.ok(uploadResponse.isSuccessful);
|
||||
assert.equal(uploadError, null);
|
||||
assert.notEqual(blobResponse, null);
|
||||
assert.ok(uploadResponse.isSuccessful);
|
||||
|
||||
// Just retrieving works fine
|
||||
blobService.getBlobToFile(containerName, blobName, fileNameTarget, function (downloadErr1) {
|
||||
test.equal(downloadErr1, null);
|
||||
assert.equal(downloadErr1, null);
|
||||
|
||||
// replace contentMD5 by a messed up one
|
||||
var blobOptions = { contentMD5: 'fake' };
|
||||
blobService.setBlobProperties(containerName, blobName, blobOptions, function (setPropErr) {
|
||||
test.equal(setPropErr, null);
|
||||
assert.equal(setPropErr, null);
|
||||
|
||||
blobService.getBlobToFile(containerName, blobName, fileNameTarget, function (downloadErr2) {
|
||||
test.notEqual(downloadErr2, null);
|
||||
test.equal(downloadErr2, 'Blob data corrupted (integrity check failed), Expected value is fake, retrieved sQqNsWTgdUEFt6mb5y4/5Q==');
|
||||
assert.notEqual(downloadErr2, null);
|
||||
assert.equal(downloadErr2, 'Blob data corrupted (integrity check failed), Expected value is fake, retrieved sQqNsWTgdUEFt6mb5y4/5Q==');
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSharedAccess: function (test) {
|
||||
test('SharedAccess', function (done) {
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames);
|
||||
var blobName = testutil.generateId(blobNamesPrefix, blobNames);
|
||||
var blobText = 'text';
|
||||
|
@ -229,9 +229,9 @@ module.exports = testCase(
|
|||
var managementBlobClient = azure.createBlobService();
|
||||
|
||||
managementBlobClient.createContainer(containerName, function (createError, container1, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(container1, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(container1, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
|
||||
var currentDate = new Date();
|
||||
var futureDate = new Date(currentDate);
|
||||
|
@ -254,24 +254,24 @@ module.exports = testCase(
|
|||
|
||||
// Writing the blob should be possible
|
||||
sharedBlobClient.createBlockBlobFromText(containerName, blobName, blobText, function (putError, blob, putResponse) {
|
||||
test.equal(putError, null);
|
||||
test.ok(putResponse.isSuccessful);
|
||||
assert.equal(putError, null);
|
||||
assert.ok(putResponse.isSuccessful);
|
||||
|
||||
// Make sure its not possible to get the blob since only write permission was given
|
||||
sharedBlobClient.getBlobToText(containerName, blobName, function (getError, content, blockBlob, getResponse) {
|
||||
test.equal(getError.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
test.equal(content, null);
|
||||
test.equal(blockBlob, null);
|
||||
test.notEqual(getResponse, null);
|
||||
assert.equal(getError.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
assert.equal(content, null);
|
||||
assert.equal(blockBlob, null);
|
||||
assert.notEqual(getResponse, null);
|
||||
if (getResponse) {
|
||||
test.equal(getResponse.isSuccessful, false);
|
||||
assert.equal(getResponse.isSuccessful, false);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function repeat(s, n) {
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
var azure = require('../../../lib/azure');
|
||||
|
@ -28,41 +28,40 @@ var blobService;
|
|||
|
||||
var testPrefix = 'filter-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('filter-tests', function () {
|
||||
setup(function (done) {
|
||||
blobtestutil.setUpTest(module.exports, testPrefix, function (err, newBlobService) {
|
||||
blobService = newBlobService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
blobtestutil.tearDownTest(module.exports, blobService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
blobtestutil.tearDownTest(module.exports, blobService, testPrefix, done);
|
||||
});
|
||||
|
||||
testNoFilter: function (test) {
|
||||
test('NoFilter', function (done) {
|
||||
blobService.getServiceProperties(function (error, serviceProperties) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(serviceProperties, null);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(serviceProperties, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSingleFilter: function (test) {
|
||||
test('SingleFilter', function (done) {
|
||||
var eventNumber = 0;
|
||||
|
||||
var loggingBlobClient = blobService.withFilter({
|
||||
handle: function (requestOptions, nextPreCallback) {
|
||||
// pre is first event to occur
|
||||
test.equal(eventNumber, 0);
|
||||
assert.equal(eventNumber, 0);
|
||||
eventNumber++;
|
||||
|
||||
if (nextPreCallback) {
|
||||
nextPreCallback(requestOptions, function (returnObject, finalCallback, nextPostCallback) {
|
||||
// post is second event to occur
|
||||
test.equal(eventNumber, 1);
|
||||
assert.equal(eventNumber, 1);
|
||||
if (nextPostCallback) {
|
||||
nextPostCallback(returnObject);
|
||||
}
|
||||
|
@ -75,23 +74,23 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
loggingBlobClient.getServiceProperties(function (error, serviceProperties) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(serviceProperties, null);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(serviceProperties, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testNestedFilters: function (test) {
|
||||
test('NestedFilters', function (done) {
|
||||
var eventNumber = 0;
|
||||
|
||||
var loggingBlobClient = blobService.withFilter({
|
||||
handle: function (requestOptions, nextPreCallback) {
|
||||
test.equal(eventNumber++, 2);
|
||||
assert.equal(eventNumber++, 2);
|
||||
|
||||
if (nextPreCallback) {
|
||||
nextPreCallback(requestOptions, function (returnObject, finalCallback, nextPostCallback) {
|
||||
test.equal(eventNumber++, 3);
|
||||
assert.equal(eventNumber++, 3);
|
||||
|
||||
if (nextPostCallback) {
|
||||
nextPostCallback(returnObject);
|
||||
|
@ -104,11 +103,11 @@ module.exports = testCase(
|
|||
}
|
||||
}).withFilter({
|
||||
handle: function (requestOptions, nextPreCallback) {
|
||||
test.equal(eventNumber++, 1);
|
||||
assert.equal(eventNumber++, 1);
|
||||
|
||||
if (nextPreCallback) {
|
||||
nextPreCallback(requestOptions, function (returnObject, finalCallback, nextPostCallback) {
|
||||
test.equal(eventNumber++, 4);
|
||||
assert.equal(eventNumber++, 4);
|
||||
|
||||
if (nextPostCallback) {
|
||||
nextPostCallback(returnObject);
|
||||
|
@ -121,11 +120,11 @@ module.exports = testCase(
|
|||
}
|
||||
}).withFilter({
|
||||
handle: function (requestOptions, nextPreCallback) {
|
||||
test.equal(eventNumber++, 0);
|
||||
assert.equal(eventNumber++, 0);
|
||||
|
||||
if (nextPreCallback) {
|
||||
nextPreCallback(requestOptions, function (returnObject, finalCallback, nextPostCallback) {
|
||||
test.equal(eventNumber++, 5);
|
||||
assert.equal(eventNumber++, 5);
|
||||
|
||||
if (nextPostCallback) {
|
||||
nextPostCallback(returnObject);
|
||||
|
@ -139,9 +138,9 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
loggingBlobClient.getServiceProperties(function (error) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var qs = require('qs');
|
||||
|
||||
|
@ -25,18 +25,8 @@ var BlobConstants = Constants.BlobConstants;
|
|||
var HeaderConstants = Constants.HeaderConstants;
|
||||
var QueryStringConstants = Constants.QueryStringConstants;
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function (callback) {
|
||||
// clean up
|
||||
callback();
|
||||
},
|
||||
|
||||
testGenerateSignatureContainer: function (test) {
|
||||
suite('sharedaccesssignature-tests', function () {
|
||||
test('GenerateSignatureContainer', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
|
@ -53,11 +43,11 @@ module.exports = testCase(
|
|||
BlobConstants.ResourceTypes.CONTAINER,
|
||||
sharedAccessPolicy);
|
||||
|
||||
test.equal(signature, 'VdlALM4TYEYYNf94Bvt3dn48TsA01wk45ltwP3zeKp4=');
|
||||
test.done();
|
||||
},
|
||||
assert.equal(signature, 'VdlALM4TYEYYNf94Bvt3dn48TsA01wk45ltwP3zeKp4=');
|
||||
done();
|
||||
});
|
||||
|
||||
testGenerateSignatureBlob: function (test) {
|
||||
test('GenerateSignatureBlob', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
|
@ -73,11 +63,11 @@ module.exports = testCase(
|
|||
BlobConstants.ResourceTypes.BLOB,
|
||||
sharedAccessPolicy);
|
||||
|
||||
test.equal(signature, '7NIEip+VOrQ5ZV80pORPK1MOsJc62wwCNcbMvE+lQ0s=');
|
||||
test.done();
|
||||
},
|
||||
assert.equal(signature, '7NIEip+VOrQ5ZV80pORPK1MOsJc62wwCNcbMvE+lQ0s=');
|
||||
done();
|
||||
});
|
||||
|
||||
testContainerSignedQueryString: function (test) {
|
||||
test('ContainerSignedQueryString', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
|
@ -95,16 +85,16 @@ module.exports = testCase(
|
|||
BlobConstants.ResourceTypes.CONTAINER,
|
||||
sharedAccessPolicy);
|
||||
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_START], '2011-10-11');
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_EXPIRY], '2011-10-12');
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_RESOURCE], BlobConstants.ResourceTypes.CONTAINER);
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_PERMISSIONS], BlobConstants.SharedAccessPermissions.READ);
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_IDENTIFIER], 'YWJjZGVmZw==');
|
||||
test.equal(queryString[QueryStringConstants.SIGNATURE], 'VdlALM4TYEYYNf94Bvt3dn48TsA01wk45ltwP3zeKp4=');
|
||||
test.done();
|
||||
},
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_START], '2011-10-11');
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_EXPIRY], '2011-10-12');
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_RESOURCE], BlobConstants.ResourceTypes.CONTAINER);
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_PERMISSIONS], BlobConstants.SharedAccessPermissions.READ);
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_IDENTIFIER], 'YWJjZGVmZw==');
|
||||
assert.equal(queryString[QueryStringConstants.SIGNATURE], 'VdlALM4TYEYYNf94Bvt3dn48TsA01wk45ltwP3zeKp4=');
|
||||
done();
|
||||
});
|
||||
|
||||
testBlobSignedQueryString: function (test) {
|
||||
test('BlobSignedQueryString', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
|
@ -121,15 +111,15 @@ module.exports = testCase(
|
|||
BlobConstants.ResourceTypes.BLOB,
|
||||
sharedAccessPolicy);
|
||||
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_START], '2011-10-11');
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_EXPIRY], '2011-10-12');
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_RESOURCE], BlobConstants.ResourceTypes.BLOB);
|
||||
test.equal(queryString[QueryStringConstants.SIGNED_PERMISSIONS], BlobConstants.SharedAccessPermissions.WRITE);
|
||||
test.equal(queryString[QueryStringConstants.SIGNATURE], 'k8uyTrn3pgLXuhwgZhxeAH6mZ/es9k2vqHPJEuIH4CE=');
|
||||
test.done();
|
||||
},
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_START], '2011-10-11');
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_EXPIRY], '2011-10-12');
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_RESOURCE], BlobConstants.ResourceTypes.BLOB);
|
||||
assert.equal(queryString[QueryStringConstants.SIGNED_PERMISSIONS], BlobConstants.SharedAccessPermissions.WRITE);
|
||||
assert.equal(queryString[QueryStringConstants.SIGNATURE], 'k8uyTrn3pgLXuhwgZhxeAH6mZ/es9k2vqHPJEuIH4CE=');
|
||||
done();
|
||||
});
|
||||
|
||||
testSignRequest: function (test) {
|
||||
test('SignRequest', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
var sharedAccessPolicy = {
|
||||
|
@ -158,9 +148,9 @@ module.exports = testCase(
|
|||
webResource.path = '/images/pic1.png?comp=metadata';
|
||||
webResource.requestUrl = '/images/pic1.png?comp=metadata';
|
||||
|
||||
credentials.signRequest(webResource, function() {
|
||||
test.equal('/images/pic1.png?comp=metadata&' + qs.stringify(queryString), webResource.requestUrl);
|
||||
test.done();
|
||||
credentials.signRequest(webResource, function () {
|
||||
assert.equal('/images/pic1.png?comp=metadata&' + qs.stringify(queryString), webResource.requestUrl);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -13,7 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var SharedKey = require('../../../lib/services/blob/sharedkey');
|
||||
var ServiceClient = require('../../../lib/services/serviceclient');
|
||||
var WebResource = require('../../../lib/http/webresource');
|
||||
|
@ -23,20 +24,19 @@ var HeaderConstants = Constants.HeaderConstants;
|
|||
|
||||
var sharedkey;
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('sharedkey-tests', function () {
|
||||
setup(function (done) {
|
||||
sharedkey = new SharedKey(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY, false);
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown(function (done) {
|
||||
// clean up
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testSignRequest: function (test) {
|
||||
test('SignRequest', function (done) {
|
||||
var webResource = WebResource.get('container');
|
||||
webResource.addOptionalQueryParam(QueryStringConstants.RESTYPE, 'container');
|
||||
webResource.addOptionalHeader(HeaderConstants.CONTENT_TYPE, '');
|
||||
|
@ -44,9 +44,9 @@ module.exports = testCase(
|
|||
webResource.addOptionalHeader(HeaderConstants.DATE_HEADER, 'Fri, 23 Sep 2011 01:37:34 GMT');
|
||||
|
||||
sharedkey.signRequest(webResource, function () {
|
||||
test.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKey devstoreaccount1:Y5R86+6XE5MH602SIyjeTwlJuQjbawv20PT4kb/F/04=');
|
||||
assert.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKey devstoreaccount1:Y5R86+6XE5MH602SIyjeTwlJuQjbawv20PT4kb/F/04=');
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -13,7 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require("path");
|
||||
var util = require('util');
|
||||
|
@ -39,16 +40,15 @@ var containerNamesPrefix = 'cont';
|
|||
|
||||
var testPrefix = 'sharedkeylite-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('sharedkeylite-tests', function () {
|
||||
setup(function (done) {
|
||||
blobtestutil.setUpTest(module.exports, testPrefix, function (err, newBlobService) {
|
||||
blobService = newBlobService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown(function (done) {
|
||||
var deleteFiles = function () {
|
||||
// delete test files
|
||||
var list = fs.readdirSync('./');
|
||||
|
@ -58,35 +58,35 @@ module.exports = testCase(
|
|||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
done();
|
||||
};
|
||||
|
||||
blobtestutil.tearDownTest(module.exports, blobService, testPrefix, deleteFiles);
|
||||
},
|
||||
});
|
||||
|
||||
testCreateContainer: function (test) {
|
||||
test('CreateContainer', function (done) {
|
||||
blobService.authenticationProvider = new SharedKeyLite(blobService.storageAccount, blobService.storageAccessKey);
|
||||
|
||||
var containerName = testutil.generateId(containerNamesPrefix, containerNames, blobtestutil.isMocked);
|
||||
|
||||
blobService.createContainer(containerName, function (createError, container1, createContainerResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(container1, null);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(container1, null);
|
||||
if (container1) {
|
||||
test.notEqual(container1.name, null);
|
||||
test.notEqual(container1.etag, null);
|
||||
test.notEqual(container1.lastModified, null);
|
||||
assert.notEqual(container1.name, null);
|
||||
assert.notEqual(container1.etag, null);
|
||||
assert.notEqual(container1.lastModified, null);
|
||||
}
|
||||
|
||||
test.equal(createContainerResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createContainerResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
// creating again will result in a duplicate error
|
||||
blobService.createContainer(containerName, function (createError2, container2) {
|
||||
test.equal(createError2.code, Constants.BlobErrorCodeStrings.CONTAINER_ALREADY_EXISTS);
|
||||
test.equal(container2, null);
|
||||
assert.equal(createError2.code, Constants.BlobErrorCodeStrings.CONTAINER_ALREADY_EXISTS);
|
||||
assert.equal(container2, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -26,15 +26,14 @@ var StorageErrorCodeStrings = Constants.StorageErrorCodeStrings;
|
|||
var queueService;
|
||||
var queueNames = generateNames('lqr', 5100);
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('listqueueresultcontinuation-tests', function () {
|
||||
setup: function (done) {
|
||||
queueService = azure.createQueueService();
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown: function (done) {
|
||||
var deleteQueuePage = function (error, queuesResult, queuesResultContinuation) {
|
||||
if (!error && queuesResult.length > 0) {
|
||||
var queueCount = 0;
|
||||
|
@ -49,21 +48,21 @@ module.exports = testCase(
|
|||
queuesResultContinuation.getNextPage(deleteQueuePage);
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
queueService.listQueues(deleteQueuePage);
|
||||
},
|
||||
});
|
||||
|
||||
testContinuationTokens: function (test) {
|
||||
test('ContinuationTokens', function (done) {
|
||||
var createdQueues = 0;
|
||||
var scheduledQueues = 0;
|
||||
var intervalId;
|
||||
|
@ -74,12 +73,12 @@ module.exports = testCase(
|
|||
|
||||
if (queuesContinuation.hasNextPage()) {
|
||||
queuesContinuation.getNextPage(function (err, nextQueues, queuesContinuation2) {
|
||||
test.equal(err, null);
|
||||
assert.equal(err, null);
|
||||
count += nextQueues.length;
|
||||
|
||||
test.equal(count, queueNames.length);
|
||||
test.equal(queuesContinuation2.hasNextPage(), false);
|
||||
test.done();
|
||||
assert.equal(count, queueNames.length);
|
||||
assert.equal(queuesContinuation2.hasNextPage(), false);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -95,7 +94,7 @@ module.exports = testCase(
|
|||
|
||||
if (scheduledQueues <= queueNames.length) {
|
||||
queueService.createQueue(queueNames[scheduledQueues - 1], function (createError) {
|
||||
test.equal(createError, null);
|
||||
assert.equal(createError, null);
|
||||
|
||||
createdQueues++;
|
||||
if (createdQueues >= queueNames.length) {
|
||||
|
@ -112,7 +111,7 @@ module.exports = testCase(
|
|||
|
||||
// Run the first batch now
|
||||
createQueue();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function generateNames(prefix, num) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -31,169 +31,168 @@ var queueNamesPrefix = 'queue';
|
|||
|
||||
var testPrefix = 'queueservice-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('queueservice-tests', function () {
|
||||
setup(function (done) {
|
||||
queuetestutil.setUpTest(module.exports, testPrefix, function (err, newQueueService) {
|
||||
queueService = newQueueService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
queuetestutil.tearDownTest(module.exports, queueService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
queuetestutil.tearDownTest(module.exports, queueService, testPrefix, done);
|
||||
});
|
||||
|
||||
getServiceProperties: function (test) {
|
||||
test('GetServiceProperties', function (done) {
|
||||
queueService.getServiceProperties(function (error, serviceProperties) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(serviceProperties, null);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(serviceProperties, null);
|
||||
|
||||
if (serviceProperties) {
|
||||
test.notEqual(serviceProperties.Logging, null);
|
||||
assert.notEqual(serviceProperties.Logging, null);
|
||||
if (serviceProperties.Logging) {
|
||||
test.notEqual(serviceProperties.Logging.RetentionPolicy);
|
||||
test.notEqual(serviceProperties.Logging.Version);
|
||||
assert.notEqual(serviceProperties.Logging.RetentionPolicy);
|
||||
assert.notEqual(serviceProperties.Logging.Version);
|
||||
}
|
||||
|
||||
if (serviceProperties.Metrics) {
|
||||
test.notEqual(serviceProperties.Metrics, null);
|
||||
test.notEqual(serviceProperties.Metrics.RetentionPolicy);
|
||||
test.notEqual(serviceProperties.Metrics.Version);
|
||||
assert.notEqual(serviceProperties.Metrics, null);
|
||||
assert.notEqual(serviceProperties.Metrics.RetentionPolicy);
|
||||
assert.notEqual(serviceProperties.Metrics.Version);
|
||||
}
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSetServiceProperties: function (test) {
|
||||
test('SetServiceProperties', function (done) {
|
||||
queueService.getServiceProperties(function (error, serviceProperties) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
serviceProperties.Logging.Read = true;
|
||||
queueService.setServiceProperties(serviceProperties, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
queueService.getServiceProperties(function (error3, serviceProperties2) {
|
||||
test.equal(error3, null);
|
||||
test.equal(serviceProperties2.Logging.Read, true);
|
||||
assert.equal(error3, null);
|
||||
assert.equal(serviceProperties2.Logging.Read, true);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testCreateQueue: function (test) {
|
||||
test('CreateQueue', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var metadata = { 'class': 'test' };
|
||||
|
||||
// Create
|
||||
queueService.createQueue(queueName, { metadata: metadata }, function (createError, queue, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(queue, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(queue, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
test.ok(queue);
|
||||
assert.ok(queue);
|
||||
if (createResponse.queue) {
|
||||
test.ok(queue.name);
|
||||
test.equal(queue.name, queueName);
|
||||
assert.ok(queue.name);
|
||||
assert.equal(queue.name, queueName);
|
||||
|
||||
test.ok(queue.metadata);
|
||||
test.equal(queue.metadata['class'], metadata['class']);
|
||||
assert.ok(queue.metadata);
|
||||
assert.equal(queue.metadata['class'], metadata['class']);
|
||||
}
|
||||
|
||||
// Get
|
||||
queueService.getQueueMetadata(queueName, function (getError, getQueue, getResponse) {
|
||||
test.equal(getError, null);
|
||||
test.ok(getResponse.isSuccessful);
|
||||
test.equal(getResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(getError, null);
|
||||
assert.ok(getResponse.isSuccessful);
|
||||
assert.equal(getResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
test.ok(getQueue);
|
||||
assert.ok(getQueue);
|
||||
if (getQueue) {
|
||||
test.ok(getQueue.name);
|
||||
test.equal(getQueue.name, queueName);
|
||||
assert.ok(getQueue.name);
|
||||
assert.equal(getQueue.name, queueName);
|
||||
|
||||
test.ok(getQueue.metadata);
|
||||
test.equal(getQueue.metadata['class'], metadata['class']);
|
||||
assert.ok(getQueue.metadata);
|
||||
assert.equal(getQueue.metadata['class'], metadata['class']);
|
||||
}
|
||||
|
||||
// Delete
|
||||
queueService.deleteQueue(queueName, function (deleteError, deleted, deleteResponse) {
|
||||
test.equal(deleteError, null);
|
||||
test.equal(deleted, true);
|
||||
test.ok(deleteResponse.isSuccessful);
|
||||
test.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
assert.equal(deleteError, null);
|
||||
assert.equal(deleted, true);
|
||||
assert.ok(deleteResponse.isSuccessful);
|
||||
assert.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testCreateQueueIfNotExists: function (test) {
|
||||
test('CreateQueueIfNotExists', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var metadata = { 'class': 'test' };
|
||||
|
||||
// Create
|
||||
queueService.createQueue(queueName, { metadata: metadata }, function (createError, queue, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(queue, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(queue, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
test.ok(queue);
|
||||
assert.ok(queue);
|
||||
if (createResponse.queue) {
|
||||
test.ok(queue.name);
|
||||
test.equal(queue.name, queueName);
|
||||
assert.ok(queue.name);
|
||||
assert.equal(queue.name, queueName);
|
||||
|
||||
test.ok(queue.metadata);
|
||||
test.equal(queue.metadata['class'], metadata['class']);
|
||||
assert.ok(queue.metadata);
|
||||
assert.equal(queue.metadata['class'], metadata['class']);
|
||||
}
|
||||
|
||||
// Try creating again
|
||||
queueService.createQueueIfNotExists(queueName, { metadata: metadata }, function (createError2, queueCreated2) {
|
||||
test.equal(createError2, null);
|
||||
test.equal(queueCreated2, false);
|
||||
assert.equal(createError2, null);
|
||||
assert.equal(queueCreated2, false);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testListQueues: function (test) {
|
||||
test('ListQueues', function (done) {
|
||||
var queueName1 = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var queueName2 = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var metadata = { 'class': 'test' };
|
||||
|
||||
queueService.listQueues({ 'include': 'metadata' }, function (listErrorEmpty, queuesEmpty) {
|
||||
test.equal(listErrorEmpty, null);
|
||||
test.notEqual(queuesEmpty, null);
|
||||
assert.equal(listErrorEmpty, null);
|
||||
assert.notEqual(queuesEmpty, null);
|
||||
if (queuesEmpty) {
|
||||
test.equal(queuesEmpty.length, 0);
|
||||
assert.equal(queuesEmpty.length, 0);
|
||||
}
|
||||
|
||||
queueService.createQueue(queueName1, function (createError1, queue1, createResponse1) {
|
||||
test.equal(createError1, null);
|
||||
test.notEqual(queue1, null);
|
||||
test.ok(createResponse1.isSuccessful);
|
||||
test.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError1, null);
|
||||
assert.notEqual(queue1, null);
|
||||
assert.ok(createResponse1.isSuccessful);
|
||||
assert.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
queueService.createQueue(queueName2, { metadata: metadata }, function (createError2, queue2, createResponse2) {
|
||||
test.equal(createError2, null);
|
||||
test.notEqual(queue2, null);
|
||||
test.ok(createResponse2.isSuccessful);
|
||||
test.equal(createResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError2, null);
|
||||
assert.notEqual(queue2, null);
|
||||
assert.ok(createResponse2.isSuccessful);
|
||||
assert.equal(createResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
queueService.listQueues({ 'include': 'metadata' }, function (listError, queues, nextMarker, listResponse) {
|
||||
test.equal(listError, null);
|
||||
test.notEqual(queues, null);
|
||||
test.ok(listResponse.isSuccessful);
|
||||
test.equal(listResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(listError, null);
|
||||
assert.notEqual(queues, null);
|
||||
assert.ok(listResponse.isSuccessful);
|
||||
assert.equal(listResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
test.ok(queues);
|
||||
assert.ok(queues);
|
||||
|
||||
var entries = 0;
|
||||
for (var queue in queues) {
|
||||
|
@ -204,102 +203,102 @@ module.exports = testCase(
|
|||
}
|
||||
else if (currentQueue.name === queueName2) {
|
||||
entries += 2;
|
||||
test.equal(currentQueue.metadata['class'], metadata['class']);
|
||||
assert.equal(currentQueue.metadata['class'], metadata['class']);
|
||||
}
|
||||
}
|
||||
|
||||
test.equal(entries, 3);
|
||||
assert.equal(entries, 3);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testCreateMessage: function (test) {
|
||||
test('CreateMessage', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var messageText1 = 'hi there';
|
||||
var messageText2 = 'bye there';
|
||||
|
||||
// Create Queue
|
||||
queueService.createQueue(queueName, function (createError1, queue1, createResponse1) {
|
||||
test.equal(createError1, null);
|
||||
test.notEqual(queue1, null);
|
||||
test.ok(createResponse1.isSuccessful);
|
||||
test.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError1, null);
|
||||
assert.notEqual(queue1, null);
|
||||
assert.ok(createResponse1.isSuccessful);
|
||||
assert.equal(createResponse1.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
// Create message
|
||||
queueService.createMessage(queueName, messageText1, function (createMessageError, message, createMessageResponse) {
|
||||
test.equal(createMessageError, null);
|
||||
test.ok(createMessageResponse.isSuccessful);
|
||||
test.equal(createMessageResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createMessageError, null);
|
||||
assert.ok(createMessageResponse.isSuccessful);
|
||||
assert.equal(createMessageResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
// Create another message
|
||||
queueService.createMessage(queueName, messageText2, function (createMessageError2, message2, createMessageResponse2) {
|
||||
test.equal(createMessageError, null);
|
||||
test.ok(createMessageResponse2.isSuccessful);
|
||||
test.equal(createMessageResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createMessageError, null);
|
||||
assert.ok(createMessageResponse2.isSuccessful);
|
||||
assert.equal(createMessageResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
// Peek message
|
||||
queueService.peekMessages(queueName, function (peekError, queueMessages, peekResponse) {
|
||||
test.equal(peekError, null);
|
||||
test.notEqual(queueMessages, null);
|
||||
assert.equal(peekError, null);
|
||||
assert.notEqual(queueMessages, null);
|
||||
|
||||
var queueMessage = queueMessages[0];
|
||||
if (queueMessage) {
|
||||
test.ok(queueMessage['messageid']);
|
||||
test.ok(queueMessage['insertiontime']);
|
||||
test.ok(queueMessage['expirationtime']);
|
||||
test.equal(queueMessage.messagetext, messageText1);
|
||||
assert.ok(queueMessage['messageid']);
|
||||
assert.ok(queueMessage['insertiontime']);
|
||||
assert.ok(queueMessage['expirationtime']);
|
||||
assert.equal(queueMessage.messagetext, messageText1);
|
||||
}
|
||||
|
||||
test.ok(peekResponse.isSuccessful);
|
||||
test.equal(peekResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.ok(peekResponse.isSuccessful);
|
||||
assert.equal(peekResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
// Get messages
|
||||
queueService.getMessages(queueName, function (getError, getQueueMessages, getResponse) {
|
||||
test.equal(getError, null);
|
||||
test.notEqual(getQueueMessages, null);
|
||||
test.equal(getQueueMessages.length, 1);
|
||||
test.ok(getResponse.isSuccessful);
|
||||
test.equal(getResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(getError, null);
|
||||
assert.notEqual(getQueueMessages, null);
|
||||
assert.equal(getQueueMessages.length, 1);
|
||||
assert.ok(getResponse.isSuccessful);
|
||||
assert.equal(getResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
var getQueueMessage = getQueueMessages[0];
|
||||
test.equal(getQueueMessage.messagetext, messageText1);
|
||||
assert.equal(getQueueMessage.messagetext, messageText1);
|
||||
|
||||
// Delete message
|
||||
queueService.deleteMessage(queueName, getQueueMessage.messageid, getQueueMessage.popreceipt, function (deleteError, deleted, deleteResponse) {
|
||||
test.equal(deleteError, null);
|
||||
test.equal(deleted, true);
|
||||
test.ok(deleteResponse.isSuccessful);
|
||||
test.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
assert.equal(deleteError, null);
|
||||
assert.equal(deleted, true);
|
||||
assert.ok(deleteResponse.isSuccessful);
|
||||
assert.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
|
||||
// Get messages again
|
||||
queueService.getMessages(queueName, function (getError2, getQueueMessages2, getResponse2) {
|
||||
test.equal(getError2, null);
|
||||
test.notEqual(getQueueMessages2, null);
|
||||
test.ok(getResponse2.isSuccessful);
|
||||
test.equal(getResponse2.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(getError2, null);
|
||||
assert.notEqual(getQueueMessages2, null);
|
||||
assert.ok(getResponse2.isSuccessful);
|
||||
assert.equal(getResponse2.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
var getQueueMessage2 = getQueueMessages2[0];
|
||||
test.equal(getQueueMessage2.messagetext, messageText2);
|
||||
assert.equal(getQueueMessage2.messagetext, messageText2);
|
||||
|
||||
// Clear messages
|
||||
queueService.clearMessages(queueName, function (clearError, clearResponse) {
|
||||
test.equal(clearError, null);
|
||||
test.ok(clearResponse.isSuccessful);
|
||||
test.equal(clearResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
assert.equal(clearError, null);
|
||||
assert.ok(clearResponse.isSuccessful);
|
||||
assert.equal(clearResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
|
||||
// Get message again should yield empty
|
||||
queueService.getMessages(queueName, function (getError3, getQueueMessage3, getResponse3) {
|
||||
test.equal(getError3, null);
|
||||
test.ok(getResponse3.isSuccessful);
|
||||
test.equal(getResponse3.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(getError3, null);
|
||||
assert.ok(getResponse3.isSuccessful);
|
||||
assert.equal(getResponse3.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
test.equal(getQueueMessage3.length, 0);
|
||||
assert.equal(getQueueMessage3.length, 0);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -309,142 +308,142 @@ module.exports = testCase(
|
|||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testCreateEmptyMessage: function (test) {
|
||||
test('CreateEmptyMessage', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
|
||||
// Create Queue
|
||||
queueService.createQueue(queueName, function (createError1) {
|
||||
test.equal(createError1, null);
|
||||
assert.equal(createError1, null);
|
||||
|
||||
// Create message
|
||||
queueService.createMessage(queueName, '', function (createMessageError, message, createMessageResponse) {
|
||||
test.equal(createMessageError, null);
|
||||
test.equal(createMessageResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createMessageError, null);
|
||||
assert.equal(createMessageResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSetQueueMetadataName: function (test) {
|
||||
test('SetQueueMetadataName', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var metadata = { '\Uc8fc\Uba39\Uc774\Uc6b4\Ub2e4': 'test' };
|
||||
|
||||
queueService.createQueue(queueName, function (createError) {
|
||||
test.equal(createError, null);
|
||||
assert.equal(createError, null);
|
||||
|
||||
// unicode headers are valid
|
||||
queueService.setQueueMetadata(queueName, metadata, function (setError) {
|
||||
test.equal(setError, null);
|
||||
test.done();
|
||||
assert.equal(setError, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSetQueueMetadata: function (test) {
|
||||
test('SetQueueMetadata', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
var metadata = { 'class': 'test' };
|
||||
|
||||
queueService.createQueue(queueName, function (createError) {
|
||||
test.equal(createError, null);
|
||||
assert.equal(createError, null);
|
||||
|
||||
queueService.setQueueMetadata(queueName, metadata, function (setError) {
|
||||
test.equal(setError, null);
|
||||
assert.equal(setError, null);
|
||||
|
||||
queueService.getQueueMetadata(queueName, function (getError, queue) {
|
||||
test.equal(getError, null);
|
||||
assert.equal(getError, null);
|
||||
|
||||
test.notEqual(queue, null);
|
||||
assert.notEqual(queue, null);
|
||||
if (queue) {
|
||||
test.notEqual(queue.metadata, null);
|
||||
assert.notEqual(queue.metadata, null);
|
||||
|
||||
test.equal(queue.metadata.class, 'test');
|
||||
assert.equal(queue.metadata.class, 'test');
|
||||
|
||||
test.done();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testGetMessages: function (test) {
|
||||
test('GetMessages', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
|
||||
queueService.createQueue(queueName, function (createError) {
|
||||
test.equal(createError, null);
|
||||
assert.equal(createError, null);
|
||||
|
||||
queueService.getMessages(queueName, function (error, emptyMessages) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(emptyMessages, null);
|
||||
test.equal(emptyMessages.length, 0);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(emptyMessages, null);
|
||||
assert.equal(emptyMessages.length, 0);
|
||||
|
||||
queueService.createMessage(queueName, 'msg1', function (error1) {
|
||||
test.equal(error1, null);
|
||||
assert.equal(error1, null);
|
||||
|
||||
queueService.createMessage(queueName, 'msg2', function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
queueService.getMessages(queueName, { peekonly: true }, function (error3, messages) {
|
||||
test.equal(error3, null);
|
||||
assert.equal(error3, null);
|
||||
|
||||
test.notEqual(messages, null);
|
||||
assert.notEqual(messages, null);
|
||||
if (messages) {
|
||||
// By default only one is returned
|
||||
test.equal(messages.length, 1);
|
||||
assert.equal(messages.length, 1);
|
||||
}
|
||||
|
||||
queueService.getMessages(queueName, { numofmessages: 2 }, function (error4, messages2) {
|
||||
test.equal(error4, null);
|
||||
test.notEqual(messages2, null);
|
||||
assert.equal(error4, null);
|
||||
assert.notEqual(messages2, null);
|
||||
|
||||
if (messages2) {
|
||||
test.equal(messages2.length, 2);
|
||||
assert.equal(messages2.length, 2);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testUpdateMessage: function (test) {
|
||||
test('UpdateMessage', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
|
||||
queueService.createQueue(queueName, function (error) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
queueService.createMessage(queueName, 'hi there', function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
queueService.getMessages(queueName, function (error3, messages) {
|
||||
test.equal(error2, null);
|
||||
test.notEqual(messages, null);
|
||||
assert.equal(error2, null);
|
||||
assert.notEqual(messages, null);
|
||||
var message = messages[0];
|
||||
|
||||
queueService.updateMessage(queueName, message.messageid, message.popreceipt, 10, { messagetext: 'bye there' }, function (error4) {
|
||||
test.equal(error4, null);
|
||||
assert.equal(error4, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testUpdateMessageEncodingPopReceipt: function (test) {
|
||||
test('UpdateMessageEncodingPopReceipt', function (done) {
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames, queuetestutil.isMocked);
|
||||
|
||||
// no messages in the queue try to update a message should give fail to update instead of blowing up on authentication
|
||||
queueService.updateMessage(queueName, 'mymsg', 'AgAAAAEAAACucgAAvMW8+dqjzAE=', 10, { messagetext: 'bye there' }, function (error) {
|
||||
test.notEqual(error, null);
|
||||
test.equal(error.code, Constants.QueueErrorCodeStrings.QUEUE_NOT_FOUND);
|
||||
assert.notEqual(error, null);
|
||||
assert.equal(error.code, Constants.QueueErrorCodeStrings.QUEUE_NOT_FOUND);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -32,28 +32,27 @@ var wrapService;
|
|||
|
||||
var testPrefix = 'wrapservice-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('wrapservice-tests', function() {
|
||||
setup(function (done) {
|
||||
wrapservicetestutil.setUpTest(module.exports, testPrefix, function (err, newWrapService) {
|
||||
wrapService = newWrapService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
wrapservicetestutil.tearDownTest(module.exports, wrapService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
wrapservicetestutil.tearDownTest(module.exports, wrapService, testPrefix, done);
|
||||
});
|
||||
|
||||
testWrapAccessToken: function (test) {
|
||||
test('WrapAccessToken', function (done) {
|
||||
var namespace = process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE];
|
||||
|
||||
wrapService.wrapAccessToken('http://' + namespace + '.servicebus.windows.net/myqueue', function (error, wrapAccessToken) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(wrapAccessToken['wrap_access_token'], null);
|
||||
test.notEqual(wrapAccessToken['wrap_access_token_expires_in'], null);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(wrapAccessToken['wrap_access_token'], null);
|
||||
assert.notEqual(wrapAccessToken['wrap_access_token_expires_in'], null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -36,39 +36,38 @@ var wrapService;
|
|||
|
||||
var testPrefix = 'wraptokenmanager-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('wraptokenmanager-tests', function () {
|
||||
setup(function (done) {
|
||||
wrapservicetestutil.setUpTest(module.exports, testPrefix, function (err, newWrapService) {
|
||||
wrapService = newWrapService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
wrapservicetestutil.tearDownTest(module.exports, wrapService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
wrapservicetestutil.tearDownTest(module.exports, wrapService, testPrefix, done);
|
||||
});
|
||||
|
||||
testGetAccessToken: function (test) {
|
||||
test('GetAccessToken', function (done) {
|
||||
wrapTokenManager = new WrapTokenManager();
|
||||
|
||||
var namespace = process.env[ServiceClient.EnvironmentVariables.AZURE_SERVICEBUS_NAMESPACE];
|
||||
var scopeUri = 'http://' + namespace + '.servicebus.windows.net/myqueue';
|
||||
|
||||
wrapTokenManager.getAccessToken(scopeUri, function (error, wrapAccessToken) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(wrapAccessToken['wrap_access_token'], null);
|
||||
test.notEqual(wrapAccessToken['wrap_access_token_expires_in'], null);
|
||||
test.notEqual(wrapAccessToken['wrap_access_token_expires_utc'], null);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(wrapAccessToken['wrap_access_token'], null);
|
||||
assert.notEqual(wrapAccessToken['wrap_access_token_expires_in'], null);
|
||||
assert.notEqual(wrapAccessToken['wrap_access_token_expires_utc'], null);
|
||||
|
||||
// trying to get an access token to the same scopeUri immediately
|
||||
// should return the same as it should still be cached
|
||||
wrapTokenManager.getAccessToken(scopeUri, function (error2, cachedWrapAccessToken) {
|
||||
test.equal(error2, null);
|
||||
test.equal(cachedWrapAccessToken, wrapAccessToken);
|
||||
assert.equal(error2, null);
|
||||
assert.equal(cachedWrapAccessToken, wrapAccessToken);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var testutil = require('../../util/util');
|
||||
|
@ -37,87 +37,86 @@ var entity1 = { PartitionKey: 'part1',
|
|||
|
||||
var testPrefix = 'batchserviceclient-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('batchserviceclient-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
tableService = newTableService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
testAddOperation: function (test) {
|
||||
test('AddOperation', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.beginBatch();
|
||||
|
||||
test.throws(function () {
|
||||
assert.throws(function () {
|
||||
tableService.commitBatch(function () { });
|
||||
});
|
||||
|
||||
tableService.createTable(tableName, null, function (createTableError, table, createTableResponse) {
|
||||
test.equal(createTableError, null);
|
||||
test.notEqual(table, null);
|
||||
test.equal(createTableResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createTableError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.equal(createTableResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.insertEntity(tableName, entity1, null, function (insertError, insertEntity, insertEntityResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.equal(insertEntity, null);
|
||||
test.equal(insertEntityResponse.statusCode, BatchServiceClient.BATCH_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.equal(insertEntity, null);
|
||||
assert.equal(insertEntityResponse.statusCode, BatchServiceClient.BATCH_CODE);
|
||||
});
|
||||
|
||||
// The operations were successfully added
|
||||
test.notEqual(tableService.operations, null);
|
||||
assert.notEqual(tableService.operations, null);
|
||||
tableService.commitBatch(function (performBatchError, performBatchOperationResponses, performBatchResponse) {
|
||||
test.equal(performBatchError, null);
|
||||
test.equal(performBatchResponse.statusCode, HttpConstants.HttpResponseCodes.ACCEPTED_CODE);
|
||||
assert.equal(performBatchError, null);
|
||||
assert.equal(performBatchResponse.statusCode, HttpConstants.HttpResponseCodes.ACCEPTED_CODE);
|
||||
|
||||
// The operations were successfully reset
|
||||
test.equal(tableService.operations, null);
|
||||
assert.equal(tableService.operations, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testHasOperations: function (test) {
|
||||
test('HasOperations', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.beginBatch();
|
||||
|
||||
test.equal(tableService.isInBatch(), true);
|
||||
test.equal(tableService.hasOperations(), false);
|
||||
assert.equal(tableService.isInBatch(), true);
|
||||
assert.equal(tableService.hasOperations(), false);
|
||||
|
||||
// Don't really need to create the table since we're not going to execute the batch
|
||||
tableService.insertEntity(tableName, entity1, null, function (insertError, insertEntity, insertEntityResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.equal(insertEntity, null);
|
||||
test.equal(insertEntityResponse.statusCode, BatchServiceClient.BATCH_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.equal(insertEntity, null);
|
||||
assert.equal(insertEntityResponse.statusCode, BatchServiceClient.BATCH_CODE);
|
||||
});
|
||||
|
||||
test.equal(tableService.isInBatch(), true);
|
||||
test.equal(tableService.hasOperations(), true);
|
||||
assert.equal(tableService.isInBatch(), true);
|
||||
assert.equal(tableService.hasOperations(), true);
|
||||
|
||||
// insert another one just to check
|
||||
tableService.insertEntity(tableName, entity1, null, function (insertError, insertEntity, insertEntityResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.equal(insertEntity, null);
|
||||
test.equal(insertEntityResponse.statusCode, BatchServiceClient.BATCH_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.equal(insertEntity, null);
|
||||
assert.equal(insertEntityResponse.statusCode, BatchServiceClient.BATCH_CODE);
|
||||
});
|
||||
|
||||
test.equal(tableService.isInBatch(), true);
|
||||
test.equal(tableService.hasOperations(), true);
|
||||
assert.equal(tableService.isInBatch(), true);
|
||||
assert.equal(tableService.hasOperations(), true);
|
||||
|
||||
tableService.rollback();
|
||||
|
||||
// rolling back should've clear the batch
|
||||
test.equal(tableService.hasOperations(), false);
|
||||
test.equal(tableService.isInBatch(), false);
|
||||
assert.equal(tableService.hasOperations(), false);
|
||||
assert.equal(tableService.isInBatch(), false);
|
||||
|
||||
test.done();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -31,15 +31,14 @@ var tableService;
|
|||
var tableNames = [];
|
||||
var tablePrefix = 'qecont';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('queryentitiesresultcontinuation-tests', function () {
|
||||
setup(function (done) {
|
||||
tableService = azure.createTableService();
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown(function (done) {
|
||||
tableService.queryTables(function (queryError, tables) {
|
||||
if (!queryError && tables.length > 0) {
|
||||
var tableCount = 0;
|
||||
|
@ -48,31 +47,31 @@ module.exports = testCase(
|
|||
tableCount++;
|
||||
|
||||
if (tableCount === tables.length) {
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testContinuationTokens: function (test) {
|
||||
test('ContinuationTokens', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames);
|
||||
var numberOfEntities = 30;
|
||||
var numberOfEntitiesPerBatch = 10;
|
||||
var numberOfEntitiesPerQuery = 10;
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.notEqual(createResponse, null);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.notEqual(createResponse, null);
|
||||
|
||||
if (createResponse) {
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
}
|
||||
|
||||
var entities = generateEntities(numberOfEntities);
|
||||
|
@ -96,25 +95,25 @@ module.exports = testCase(
|
|||
.top(numberOfEntitiesPerQuery);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation) {
|
||||
test.equal(queryError, null);
|
||||
test.notEqual(entries, null);
|
||||
assert.equal(queryError, null);
|
||||
assert.notEqual(entries, null);
|
||||
|
||||
if (entries) {
|
||||
var count = entries.length;
|
||||
|
||||
if (entriesContinuation.hasNextPage()) {
|
||||
entriesContinuation.getNextPage(function (queryError2, entries2, entriesContinuation2) {
|
||||
test.equal(queryError2, null);
|
||||
assert.equal(queryError2, null);
|
||||
count += entries2.length;
|
||||
|
||||
if (entriesContinuation2.hasNextPage()) {
|
||||
entriesContinuation2.getNextPage(function (queryError3, entries3, entriesContinuation3) {
|
||||
test.equal(queryError3, null);
|
||||
assert.equal(queryError3, null);
|
||||
count += entries3.length;
|
||||
|
||||
test.equal(count, numberOfEntities);
|
||||
test.equal(entriesContinuation3.hasNextPage(), false);
|
||||
test.done();
|
||||
assert.equal(count, numberOfEntities);
|
||||
assert.equal(entriesContinuation3.hasNextPage(), false);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -125,26 +124,26 @@ module.exports = testCase(
|
|||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testNullNextRowKey: function (test) {
|
||||
test('NullNextRowKey', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames);
|
||||
var tableQuery = TableQuery.select().from(tableName);
|
||||
|
||||
tableService.createTable(tableName, function (createError) {
|
||||
test.equal(createError, null);
|
||||
assert.equal(createError, null);
|
||||
|
||||
var queryEntitiesResultContinuation = new QueryEntitiesResultContinuation(tableService, tableQuery, 'part1', null);
|
||||
test.equal(queryEntitiesResultContinuation.hasNextPage(), true);
|
||||
assert.equal(queryEntitiesResultContinuation.hasNextPage(), true);
|
||||
|
||||
queryEntitiesResultContinuation.getNextPage(function (error) {
|
||||
// There should be no error when fetching the next page with a null next row key
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function generateNames (prefix, num) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -29,15 +29,14 @@ var tableService;
|
|||
var tableNames = [];
|
||||
var tablePrefix = 'tablecont';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('querytablesresultcontinuation-tests', function () {
|
||||
setup(function (done) {
|
||||
tableService = azure.createTableService();
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown(function (done) {
|
||||
var deleteTablePage = function (error, tablesResult, tablesResultContinuation) {
|
||||
if (!error && tablesResult.length > 0) {
|
||||
var tableCount = 0;
|
||||
|
@ -52,21 +51,21 @@ module.exports = testCase(
|
|||
tablesResultContinuation.getNextPage(deleteTablePage);
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
tableService.queryTables(deleteTablePage);
|
||||
},
|
||||
});
|
||||
|
||||
testContinuationTokens: function (test) {
|
||||
test('ContinuationTokens', function (done) {
|
||||
var createdTables = 0;
|
||||
var scheduledTables = 0;
|
||||
var tableLength = 1200;
|
||||
|
@ -85,7 +84,7 @@ module.exports = testCase(
|
|||
|
||||
if (tablesContinuation.hasNextPage()) {
|
||||
tablesContinuation.getNextPage(function (err, nextTables, tablesContinuation2) {
|
||||
test.equal(err, null);
|
||||
assert.equal(err, null);
|
||||
count += nextTables.length;
|
||||
|
||||
nextTables.forEach(function (t) {
|
||||
|
@ -96,9 +95,9 @@ module.exports = testCase(
|
|||
}
|
||||
});
|
||||
|
||||
test.equal(count, tableNames.length);
|
||||
test.equal(tablesContinuation2.hasNextPage(), false);
|
||||
test.done();
|
||||
assert.equal(count, tableNames.length);
|
||||
assert.equal(tablesContinuation2.hasNextPage(), false);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -114,7 +113,7 @@ module.exports = testCase(
|
|||
|
||||
if (scheduledTables <= tableLength) {
|
||||
tableService.createTable(testutil.generateId(tablePrefix, tableNames), function (createError) {
|
||||
test.equal(createError, null);
|
||||
assert.equal(createError, null);
|
||||
|
||||
createdTables++;
|
||||
if (createdTables >= tableLength) {
|
||||
|
@ -131,5 +130,5 @@ module.exports = testCase(
|
|||
|
||||
// Run the first batch now
|
||||
createTable();
|
||||
}
|
||||
});
|
||||
});
|
|
@ -13,7 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var SharedKeyLiteTable = require('../../../lib/services/table/sharedkeylitetable');
|
||||
var ServiceClient = require('../../../lib/services/serviceclient');
|
||||
var WebResource = require('../../../lib/http/webresource');
|
||||
|
@ -23,33 +24,32 @@ var QueryStringConstants = Constants.QueryStringConstants;
|
|||
|
||||
var sharedkey;
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('sharedkeylitetable-tests', function () {
|
||||
setup(function (done) {
|
||||
sharedkey = new SharedKeyLiteTable(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY, false);
|
||||
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
teardown(function (done) {
|
||||
// clean up
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testSignRequest: function (test) {
|
||||
test('SignRequest', function (done) {
|
||||
var webResource = WebResource.get('Tables');
|
||||
webResource.addOptionalHeader(HeaderConstants.CONTENT_TYPE, 'application/atom+xml');
|
||||
webResource.addOptionalHeader(HeaderConstants.STORAGE_VERSION_HEADER, HeaderConstants.TARGET_STORAGE_VERSION);
|
||||
webResource.addOptionalHeader(HeaderConstants.DATE_HEADER, 'Fri, 23 Sep 2011 01:37:34 GMT');
|
||||
|
||||
sharedkey.signRequest(webResource, function () {
|
||||
test.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKeyLite devstoreaccount1:c8dPVfX0lX++AxpLHNLSU8Afdd7MIoIDNX0xzo1satk=');
|
||||
assert.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKeyLite devstoreaccount1:c8dPVfX0lX++AxpLHNLSU8Afdd7MIoIDNX0xzo1satk=');
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSignRequestServiceProperties: function (test) {
|
||||
test('SignRequestServiceProperties', function (done) {
|
||||
var webResource = WebResource.get();
|
||||
webResource.addOptionalQueryParam(QueryStringConstants.RESTYPE, 'service');
|
||||
webResource.addOptionalQueryParam(QueryStringConstants.COMP, 'properties');
|
||||
|
@ -58,9 +58,9 @@ module.exports = testCase(
|
|||
webResource.addOptionalHeader(HeaderConstants.DATE_HEADER, 'Mon, 05 Dec 2011 17:55:02 GMT');
|
||||
|
||||
sharedkey.signRequest(webResource, function() {
|
||||
test.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKeyLite devstoreaccount1:b89upLBiJ54w3Ju3zBv4GzThZGj/M6C3CdTm1BySj28=');
|
||||
assert.equal(webResource.headers[HeaderConstants.AUTHORIZATION], 'SharedKeyLite devstoreaccount1:b89upLBiJ54w3Ju3zBv4GzThZGj/M6C3CdTm1BySj28=');
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -50,52 +50,51 @@ var tablePrefix = 'sharedkeytable';
|
|||
|
||||
var testPrefix = 'sharedkeytable-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('sharedkeytable-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
tableService = newTableService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
testCreateTable: function (test) {
|
||||
test('CreateTable', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.authenticationProvider = new SharedKeyLiteTable(tableService.storageAccount, tableService.storageAccessKey);
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
test.ok(table);
|
||||
assert.ok(table);
|
||||
if (table) {
|
||||
test.ok(table.TableName);
|
||||
test.equal(table.TableName, tableName);
|
||||
assert.ok(table.TableName);
|
||||
assert.equal(table.TableName, tableName);
|
||||
|
||||
test.ok(table.id);
|
||||
test.equal(table.id, createResponse.body['id']);
|
||||
assert.ok(table.id);
|
||||
assert.equal(table.id, createResponse.body['id']);
|
||||
|
||||
test.ok(table.link);
|
||||
test.equal(table.link, createResponse.body['link']['@']['href']);
|
||||
assert.ok(table.link);
|
||||
assert.equal(table.link, createResponse.body['link']['@']['href']);
|
||||
|
||||
test.ok(table.updated);
|
||||
test.equal(table.updated, createResponse.body['updated']);
|
||||
assert.ok(table.updated);
|
||||
assert.equal(table.updated, createResponse.body['updated']);
|
||||
}
|
||||
|
||||
// check that the table exists
|
||||
tableService.getTable(tableName, function (existsError, tableResponse, existsResponse) {
|
||||
test.equal(existsError, null);
|
||||
test.notEqual(tableResponse, null);
|
||||
test.ok(existsResponse.isSuccessful);
|
||||
test.equal(existsResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
test.done();
|
||||
assert.equal(existsError, null);
|
||||
assert.notEqual(tableResponse, null);
|
||||
assert.ok(existsResponse.isSuccessful);
|
||||
assert.equal(existsResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var TableQuery = require('../../../lib/services/table/tablequery');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -21,113 +21,103 @@ var Constants = require('../../../lib/util/constants');
|
|||
var QueryStringConstants = Constants.QueryStringConstants;
|
||||
var util = require('util');
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function (callback) {
|
||||
// clean up.
|
||||
callback();
|
||||
},
|
||||
|
||||
testSelect: function (test) {
|
||||
suite('tablequery-tests', function () {
|
||||
test('Select', function (done) {
|
||||
var tableQuery = TableQuery.select('field1', 'field2')
|
||||
.from('Table');
|
||||
|
||||
test.equal('field1,field2', tableQuery.toQueryObject()['$select']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('field1,field2', tableQuery.toQueryObject()['$select']);
|
||||
done();
|
||||
});
|
||||
|
||||
testQueryWithSingle: function (test) {
|
||||
test('QueryWithSingle', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.whereKeys('test', '123');
|
||||
|
||||
test.equal('Table(PartitionKey=\'test\', RowKey=\'123\')', tableQuery.toPath());
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table(PartitionKey=\'test\', RowKey=\'123\')', tableQuery.toPath());
|
||||
done();
|
||||
});
|
||||
|
||||
testQueryWithTop: function (test) {
|
||||
test('QueryWithTop', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.top(10);
|
||||
|
||||
test.equal('Table()', tableQuery.toPath());
|
||||
test.equal(10, tableQuery.toQueryObject()['$top']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table()', tableQuery.toPath());
|
||||
assert.equal(10, tableQuery.toQueryObject()['$top']);
|
||||
done();
|
||||
});
|
||||
|
||||
testQueryWithOrderBy: function (test) {
|
||||
test('QueryWithOrderBy', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.orderBy('Name', 'asc');
|
||||
|
||||
test.equal('Table()', tableQuery.toPath());
|
||||
test.equal(azureutil.encodeUri('Name asc'), tableQuery.toQueryObject()['$orderby']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table()', tableQuery.toPath());
|
||||
assert.equal(azureutil.encodeUri('Name asc'), tableQuery.toQueryObject()['$orderby']);
|
||||
done();
|
||||
});
|
||||
|
||||
testOrderByMultipleQuery: function (test) {
|
||||
test('OrderByMultipleQuery', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.orderBy('Name', 'asc')
|
||||
.orderBy('Visible', 'desc');
|
||||
|
||||
test.equal('Table()', tableQuery.toPath());
|
||||
test.equal(azureutil.encodeUri('Name asc') + ',' + azureutil.encodeUri('Visible desc'), tableQuery.toQueryObject()['$orderby']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table()', tableQuery.toPath());
|
||||
assert.equal(azureutil.encodeUri('Name asc') + ',' + azureutil.encodeUri('Visible desc'), tableQuery.toQueryObject()['$orderby']);
|
||||
done();
|
||||
});
|
||||
|
||||
testQueryWithWhere: function (test) {
|
||||
test('QueryWithWhere', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.where('Name eq ?', 'Person');
|
||||
|
||||
test.equal('Table()', tableQuery.toPath());
|
||||
test.equal(azureutil.encodeUri('Name eq \'Person\''), tableQuery.toQueryObject()['$filter']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table()', tableQuery.toPath());
|
||||
assert.equal(azureutil.encodeUri('Name eq \'Person\''), tableQuery.toQueryObject()['$filter']);
|
||||
done();
|
||||
});
|
||||
|
||||
testQueryWithParameterArray: function (test) {
|
||||
test('QueryWithParameterArray', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.where('Name eq ? or Name eq ?', 'Person1', 'Person2');
|
||||
|
||||
test.equal('Table()', tableQuery.toPath());
|
||||
test.equal(azureutil.encodeUri('Name eq \'Person1\' or Name eq \'Person2\''), tableQuery.toQueryObject()['$filter']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table()', tableQuery.toPath());
|
||||
assert.equal(azureutil.encodeUri('Name eq \'Person1\' or Name eq \'Person2\''), tableQuery.toQueryObject()['$filter']);
|
||||
done();
|
||||
});
|
||||
|
||||
testQueryWithAnd: function (test) {
|
||||
test('QueryWithAnd', function (done) {
|
||||
var tableQuery = TableQuery.select()
|
||||
.from('Table')
|
||||
.where('Name eq ?', 'Person')
|
||||
.and('Visible eq true');
|
||||
|
||||
test.equal('Table()', tableQuery.toPath());
|
||||
test.equal(azureutil.encodeUri('Name eq \'Person\' and Visible eq true'), tableQuery.toQueryObject()['$filter']);
|
||||
test.done();
|
||||
},
|
||||
assert.equal('Table()', tableQuery.toPath());
|
||||
assert.equal(azureutil.encodeUri('Name eq \'Person\' and Visible eq true'), tableQuery.toQueryObject()['$filter']);
|
||||
done();
|
||||
});
|
||||
|
||||
testReplaceOperators: function (test) {
|
||||
test('ReplaceOperators', function (done) {
|
||||
var tableQuery = TableQuery.select();
|
||||
|
||||
test.equal(tableQuery._replaceOperators(' == == '), ' eq eq ');
|
||||
test.equal(tableQuery._replaceOperators(' > > '), ' gt gt ');
|
||||
test.equal(tableQuery._replaceOperators(' < < '), ' lt lt ');
|
||||
test.equal(tableQuery._replaceOperators(' >= >= '), ' ge ge ');
|
||||
test.equal(tableQuery._replaceOperators(' <= <= '), ' le le ');
|
||||
test.equal(tableQuery._replaceOperators(' != != '), ' ne ne ');
|
||||
test.equal(tableQuery._replaceOperators(' && && '), ' and and ');
|
||||
test.equal(tableQuery._replaceOperators(' || || '), ' or or ');
|
||||
test.equal(tableQuery._replaceOperators('! !'), 'not not');
|
||||
assert.equal(tableQuery._replaceOperators(' == == '), ' eq eq ');
|
||||
assert.equal(tableQuery._replaceOperators(' > > '), ' gt gt ');
|
||||
assert.equal(tableQuery._replaceOperators(' < < '), ' lt lt ');
|
||||
assert.equal(tableQuery._replaceOperators(' >= >= '), ' ge ge ');
|
||||
assert.equal(tableQuery._replaceOperators(' <= <= '), ' le le ');
|
||||
assert.equal(tableQuery._replaceOperators(' != != '), ' ne ne ');
|
||||
assert.equal(tableQuery._replaceOperators(' && && '), ' and and ');
|
||||
assert.equal(tableQuery._replaceOperators(' || || '), ' or or ');
|
||||
assert.equal(tableQuery._replaceOperators('! !'), 'not not');
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testComplexPartitionKey: function (test) {
|
||||
test('ComplexPartitionKey', function (done) {
|
||||
var complexPartitionKey = 'aHR0cDovL2ZlZWRzLmZlZWRidXJuZXIuY29tL2ppbXdhbmdzYmxvZw==';
|
||||
var encodedComplexPartitionKey = 'aHR0cDovL2ZlZWRzLmZlZWRidXJuZXIuY29tL2ppbXdhbmdzYmxvZw%3D%3D';
|
||||
|
||||
|
@ -135,14 +125,14 @@ module.exports = testCase(
|
|||
.where('PartitionKey == ?', complexPartitionKey);
|
||||
|
||||
var queryObject = tableQuery.toQueryObject();
|
||||
test.notEqual(queryObject[QueryStringConstants.FILTER].indexOf(encodedComplexPartitionKey), -1);
|
||||
assert.notEqual(queryObject[QueryStringConstants.FILTER].indexOf(encodedComplexPartitionKey), -1);
|
||||
|
||||
tableQuery = TableQuery.select()
|
||||
.where("PartitionKey == '" + complexPartitionKey + "'");
|
||||
|
||||
queryObject = tableQuery.toQueryObject();
|
||||
test.notEqual(queryObject[QueryStringConstants.FILTER].indexOf(encodedComplexPartitionKey), -1);
|
||||
assert.notEqual(queryObject[QueryStringConstants.FILTER].indexOf(encodedComplexPartitionKey), -1);
|
||||
|
||||
test.done();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -32,26 +32,25 @@ var tablePrefix = 'tablebatch';
|
|||
|
||||
var testPrefix = 'tableservice-batch-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('tableservice-batch-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
tableService = newTableService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
testQueryEntities_All: function (test) {
|
||||
test('QueryEntities_All', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
|
||||
var entities = generateEntities(20);
|
||||
|
||||
|
@ -61,33 +60,33 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.equal(batchError, null);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
.from(tableName);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
assert.equal(queryError, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
|
||||
if (entries) {
|
||||
test.equal(entries.length, 20);
|
||||
assert.equal(entries.length, 20);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testQueryEntities_Single1: function (test) {
|
||||
test('QueryEntities_Single1', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
|
||||
var entities = generateEntities(20);
|
||||
|
||||
|
@ -97,34 +96,34 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.equal(batchError, null);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
.from(tableName)
|
||||
.whereKeys(entities[0].PartitionKey, entities[0].RowKey);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
assert.equal(queryError, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
|
||||
if (entries) {
|
||||
test.equal(entries.length, 1);
|
||||
assert.equal(entries.length, 1);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testQueryEntities_Single2: function (test) {
|
||||
test('QueryEntities_Single2', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
|
||||
var entities = generateEntities(20);
|
||||
|
||||
|
@ -134,29 +133,29 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.equal(batchError, null);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
|
||||
tableService.queryEntity(tableName, entities[0].PartitionKey, entities[0].RowKey, function (queryError, entry, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
test.notEqual(entry, null);
|
||||
test.equal(entry.PartitionKey, entities[0].PartitionKey);
|
||||
test.equal(entry.RowKey, entities[0].RowKey);
|
||||
assert.equal(queryError, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
assert.notEqual(entry, null);
|
||||
assert.equal(entry.PartitionKey, entities[0].PartitionKey);
|
||||
assert.equal(entry.RowKey, entities[0].RowKey);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testRetrieveEntities_TableQuery1: function (test) {
|
||||
test('RetrieveEntities_TableQuery1', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
|
||||
var entities = generateEntities(20);
|
||||
|
||||
|
@ -166,8 +165,8 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.equal(batchError, null);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
.from(tableName)
|
||||
|
@ -175,32 +174,32 @@ module.exports = testCase(
|
|||
.and('RowKey eq ?', entities[0].RowKey);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.notEqual(entries, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
assert.equal(queryError, null);
|
||||
assert.notEqual(entries, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
|
||||
if (entries) {
|
||||
test.equal(entries.length, 1);
|
||||
assert.equal(entries.length, 1);
|
||||
if (entries[0]) {
|
||||
test.equal(entries[0].address, entities[0].address);
|
||||
test.equal(entries[0].RowKey, entities[0].RowKey);
|
||||
test.equal(entries[0].PartitionKey, entities[0].PartitionKey);
|
||||
assert.equal(entries[0].address, entities[0].address);
|
||||
assert.equal(entries[0].RowKey, entities[0].RowKey);
|
||||
assert.equal(entries[0].PartitionKey, entities[0].PartitionKey);
|
||||
}
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testRetrieveEntities_TableQuery2: function (test) {
|
||||
test('RetrieveEntities_TableQuery2', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
|
||||
var entities = generateEntities(20);
|
||||
|
||||
|
@ -216,11 +215,11 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
assert.equal(batchError, null);
|
||||
|
||||
test.notEqual(batchResponse, null);
|
||||
assert.notEqual(batchResponse, null);
|
||||
if (batchResponse) {
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
}
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
|
@ -229,39 +228,39 @@ module.exports = testCase(
|
|||
.and('PartitionKey eq ?', entities[0].PartitionKey);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.notEqual(entries, null);
|
||||
assert.equal(queryError, null);
|
||||
assert.notEqual(entries, null);
|
||||
if (entries) {
|
||||
test.equal(entries.length, 1);
|
||||
assert.equal(entries.length, 1);
|
||||
|
||||
if (entries[0]) {
|
||||
test.equal(entries[0].address, entities[0].address);
|
||||
test.equal(entries[0].RowKey, entities[0].RowKey);
|
||||
test.equal(entries[0].PartitionKey, entities[0].PartitionKey);
|
||||
assert.equal(entries[0].address, entities[0].address);
|
||||
assert.equal(entries[0].RowKey, entities[0].RowKey);
|
||||
assert.equal(entries[0].PartitionKey, entities[0].PartitionKey);
|
||||
}
|
||||
}
|
||||
|
||||
test.notEqual(queryResponse, null);
|
||||
assert.notEqual(queryResponse, null);
|
||||
if (queryResponse) {
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testRetrieveEntities_Top: function (test) {
|
||||
test('RetrieveEntities_Top', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
|
||||
test.notEqual(createResponse, null);
|
||||
assert.notEqual(createResponse, null);
|
||||
if (createResponse) {
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
}
|
||||
|
||||
var entities = generateEntities(20);
|
||||
|
@ -272,11 +271,11 @@ module.exports = testCase(
|
|||
});
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
assert.equal(batchError, null);
|
||||
|
||||
test.notEqual(batchResponse, null);
|
||||
assert.notEqual(batchResponse, null);
|
||||
if (batchResponse) {
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
}
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
|
@ -284,34 +283,34 @@ module.exports = testCase(
|
|||
.top(4);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
assert.equal(queryError, null);
|
||||
|
||||
test.notEqual(entries, null);
|
||||
assert.notEqual(entries, null);
|
||||
if (entries) {
|
||||
test.equal(entries.length, 4);
|
||||
assert.equal(entries.length, 4);
|
||||
}
|
||||
|
||||
test.notEqual(queryResponse, null);
|
||||
assert.notEqual(queryResponse, null);
|
||||
if (queryResponse) {
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testFailBatch: function (test) {
|
||||
test('FailBatch', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
|
||||
test.notEqual(createResponse, null);
|
||||
assert.notEqual(createResponse, null);
|
||||
if (createResponse) {
|
||||
test.ok(createResponse.isSuccessful);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
}
|
||||
|
||||
var simpleEntity = {
|
||||
|
@ -329,22 +328,22 @@ module.exports = testCase(
|
|||
tableService.updateEntity(tableName, simpleEntity);
|
||||
|
||||
tableService.commitBatch(function (batchError, performBatchOperationResponses, batchResponse) {
|
||||
test.equal(batchError, null);
|
||||
assert.equal(batchError, null);
|
||||
|
||||
test.notEqual(performBatchOperationResponses, null);
|
||||
test.equal(performBatchOperationResponses.length, 1);
|
||||
test.notEqual(performBatchOperationResponses[0].error, null);
|
||||
test.equal(performBatchOperationResponses[0].error.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
assert.notEqual(performBatchOperationResponses, null);
|
||||
assert.equal(performBatchOperationResponses.length, 1);
|
||||
assert.notEqual(performBatchOperationResponses[0].error, null);
|
||||
assert.equal(performBatchOperationResponses[0].error.code, Constants.StorageErrorCodeStrings.RESOURCE_NOT_FOUND);
|
||||
|
||||
test.notEqual(batchResponse, null);
|
||||
assert.notEqual(batchResponse, null);
|
||||
if (batchResponse) {
|
||||
test.ok(batchResponse.isSuccessful);
|
||||
assert.ok(batchResponse.isSuccessful);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function generateEntities(count) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -48,42 +48,41 @@ var tablePrefix = 'tablequery';
|
|||
|
||||
var testPrefix = 'tableservice-tablequery-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('tableservice-tablequery-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
tableService = newTableService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
testSelect: function (test) {
|
||||
test('Select', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (error1) {
|
||||
test.equal(error1, null);
|
||||
assert.equal(error1, null);
|
||||
|
||||
tableService.insertEntity(tableName, entity1, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
// Select specific field
|
||||
var tableQuery = TableQuery.select('field1')
|
||||
.from(tableName);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (error3, entities1) {
|
||||
test.equal(error3, null);
|
||||
assert.equal(error3, null);
|
||||
|
||||
test.notEqual(entities1, null);
|
||||
assert.notEqual(entities1, null);
|
||||
|
||||
if (entities1) {
|
||||
test.equal(entities1.length, 1);
|
||||
assert.equal(entities1.length, 1);
|
||||
var entityResult1 = entities1[0];
|
||||
test.equal(entityResult1.field1, entity1.field1);
|
||||
test.equal(entityResult1.field2, undefined);
|
||||
assert.equal(entityResult1.field1, entity1.field1);
|
||||
assert.equal(entityResult1.field2, undefined);
|
||||
}
|
||||
|
||||
// Select all fields
|
||||
|
@ -91,23 +90,23 @@ module.exports = testCase(
|
|||
.from(tableName);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (error4, entities2) {
|
||||
test.equal(error3, null);
|
||||
assert.equal(error3, null);
|
||||
|
||||
test.notEqual(entities2, null);
|
||||
assert.notEqual(entities2, null);
|
||||
|
||||
if (entities2) {
|
||||
test.equal(entities2.length, 1);
|
||||
assert.equal(entities2.length, 1);
|
||||
var entityResult2 = entities2[0];
|
||||
test.equal(entityResult2.field1, entity1.field1);
|
||||
test.equal(entityResult2.field2, entity1.field2);
|
||||
assert.equal(entityResult2.field1, entity1.field1);
|
||||
assert.equal(entityResult2.field2, entity1.field2);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function generateEntities(count) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var azure = require('../../../lib/azure');
|
||||
var azureutil = require('../../../lib/util/util');
|
||||
|
@ -51,428 +51,427 @@ var tablePrefix = 'tableservice';
|
|||
|
||||
var testPrefix = 'tableservice-tests';
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
suite('tableservice-tests', function () {
|
||||
setup(function (done) {
|
||||
tabletestutil.setUpTest(module.exports, testPrefix, function (err, newTableService) {
|
||||
tableService = newTableService;
|
||||
callback();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
tearDown: function (callback) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, callback);
|
||||
},
|
||||
teardown(function (done) {
|
||||
tabletestutil.tearDownTest(module.exports, tableService, testPrefix, done);
|
||||
});
|
||||
|
||||
getServiceProperties: function (test) {
|
||||
test('GetServiceProperties', function (done) {
|
||||
tableService.getServiceProperties(function (error, serviceProperties) {
|
||||
test.equal(error, null);
|
||||
test.notEqual(serviceProperties, null);
|
||||
assert.equal(error, null);
|
||||
assert.notEqual(serviceProperties, null);
|
||||
|
||||
if (serviceProperties) {
|
||||
test.notEqual(serviceProperties.Logging, null);
|
||||
assert.notEqual(serviceProperties.Logging, null);
|
||||
if (serviceProperties.Logging) {
|
||||
test.notEqual(serviceProperties.Logging.RetentionPolicy);
|
||||
test.notEqual(serviceProperties.Logging.Version);
|
||||
assert.notEqual(serviceProperties.Logging.RetentionPolicy);
|
||||
assert.notEqual(serviceProperties.Logging.Version);
|
||||
}
|
||||
|
||||
if (serviceProperties.Metrics) {
|
||||
test.notEqual(serviceProperties.Metrics, null);
|
||||
test.notEqual(serviceProperties.Metrics.RetentionPolicy);
|
||||
test.notEqual(serviceProperties.Metrics.Version);
|
||||
assert.notEqual(serviceProperties.Metrics, null);
|
||||
assert.notEqual(serviceProperties.Metrics.RetentionPolicy);
|
||||
assert.notEqual(serviceProperties.Metrics.Version);
|
||||
}
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testSetServiceProperties: function (test) {
|
||||
test('SetServiceProperties', function (done) {
|
||||
tableService.getServiceProperties(function (error, serviceProperties) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
serviceProperties.Logging.Read = true;
|
||||
tableService.setServiceProperties(serviceProperties, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
tableService.getServiceProperties(function (error3, serviceProperties2) {
|
||||
test.equal(error3, null);
|
||||
test.equal(serviceProperties2.Logging.Read, true);
|
||||
assert.equal(error3, null);
|
||||
assert.equal(serviceProperties2.Logging.Read, true);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testCreateTable: function (test) {
|
||||
test('CreateTable', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
test.ok(table);
|
||||
assert.ok(table);
|
||||
if (table) {
|
||||
test.ok(table.TableName);
|
||||
test.equal(table.TableName, tableName);
|
||||
assert.ok(table.TableName);
|
||||
assert.equal(table.TableName, tableName);
|
||||
|
||||
test.ok(table.id);
|
||||
test.equal(table.id, createResponse.body['id']);
|
||||
assert.ok(table.id);
|
||||
assert.equal(table.id, createResponse.body['id']);
|
||||
|
||||
test.ok(table.link);
|
||||
test.equal(table.link, createResponse.body['link']['@']['href']);
|
||||
assert.ok(table.link);
|
||||
assert.equal(table.link, createResponse.body['link']['@']['href']);
|
||||
|
||||
test.ok(table.updated);
|
||||
test.equal(table.updated, createResponse.body['updated']);
|
||||
assert.ok(table.updated);
|
||||
assert.equal(table.updated, createResponse.body['updated']);
|
||||
}
|
||||
|
||||
// check that the table exists
|
||||
tableService.getTable(tableName, function (existsError, tableResponse, existsResponse) {
|
||||
test.equal(existsError, null);
|
||||
test.notEqual(tableResponse, null);
|
||||
test.ok(existsResponse.isSuccessful);
|
||||
test.equal(existsResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
test.done();
|
||||
assert.equal(existsError, null);
|
||||
assert.notEqual(tableResponse, null);
|
||||
assert.ok(existsResponse.isSuccessful);
|
||||
assert.equal(existsResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testCreateTableIfNotExists: function (test) {
|
||||
test('CreateTableIfNotExists', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
test.ok(table);
|
||||
assert.ok(table);
|
||||
if (table) {
|
||||
test.ok(table.TableName);
|
||||
test.equal(table.TableName, tableName);
|
||||
assert.ok(table.TableName);
|
||||
assert.equal(table.TableName, tableName);
|
||||
|
||||
test.ok(table.id);
|
||||
test.equal(table.id, createResponse.body['id']);
|
||||
assert.ok(table.id);
|
||||
assert.equal(table.id, createResponse.body['id']);
|
||||
|
||||
test.ok(table.link);
|
||||
test.equal(table.link, createResponse.body['link']['@']['href']);
|
||||
assert.ok(table.link);
|
||||
assert.equal(table.link, createResponse.body['link']['@']['href']);
|
||||
|
||||
test.ok(table.updated);
|
||||
test.equal(table.updated, createResponse.body['updated']);
|
||||
assert.ok(table.updated);
|
||||
assert.equal(table.updated, createResponse.body['updated']);
|
||||
}
|
||||
|
||||
// trying to create again with if not exists should be fine
|
||||
tableService.createTableIfNotExists(tableName, function (createError2, created2) {
|
||||
test.equal(createError2, null);
|
||||
test.equal(created2, false);
|
||||
assert.equal(createError2, null);
|
||||
assert.equal(created2, false);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testQueryTable: function (test) {
|
||||
test('QueryTable', function (done) {
|
||||
var tableName1 = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
var tableName2 = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.queryTables(function (queryErrorEmpty, tablesEmpty) {
|
||||
test.equal(queryErrorEmpty, null);
|
||||
test.notEqual(tablesEmpty, null);
|
||||
assert.equal(queryErrorEmpty, null);
|
||||
assert.notEqual(tablesEmpty, null);
|
||||
if (tablesEmpty) {
|
||||
test.equal(tablesEmpty.length, 0);
|
||||
assert.equal(tablesEmpty.length, 0);
|
||||
}
|
||||
|
||||
tableService.createTable(tableName1, function (createError, table1, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table1, null);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table1, null);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.createTable(tableName2, function (createError2, table2, createResponse2) {
|
||||
test.equal(createError2, null);
|
||||
test.notEqual(table2, null);
|
||||
test.equal(createResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError2, null);
|
||||
assert.notEqual(table2, null);
|
||||
assert.equal(createResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.queryTables(function (queryError, tables, tablesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.notEqual(tables, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
test.equal(queryResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(queryError, null);
|
||||
assert.notEqual(tables, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
assert.equal(queryResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
var entries = 0;
|
||||
tables.forEach(function (currentTable) {
|
||||
if (currentTable.TableName === tableName1) {
|
||||
entries += 1;
|
||||
test.ok(currentTable.id);
|
||||
test.ok(currentTable.link);
|
||||
test.ok(currentTable.updated);
|
||||
assert.ok(currentTable.id);
|
||||
assert.ok(currentTable.link);
|
||||
assert.ok(currentTable.updated);
|
||||
}
|
||||
else if (currentTable.TableName === tableName2) {
|
||||
entries += 2;
|
||||
test.ok(currentTable.id);
|
||||
test.ok(currentTable.link);
|
||||
test.ok(currentTable.updated);
|
||||
assert.ok(currentTable.id);
|
||||
assert.ok(currentTable.link);
|
||||
assert.ok(currentTable.updated);
|
||||
}
|
||||
});
|
||||
|
||||
test.equal(entries, 3);
|
||||
assert.equal(entries, 3);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testDeleteTable: function (test) {
|
||||
test('DeleteTable', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.deleteTable(tableName, function (deleteError, deleted, deleteResponse) {
|
||||
test.equal(deleteError, null);
|
||||
test.equal(deleted, true);
|
||||
test.ok(deleteResponse.isSuccessful);
|
||||
test.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
test.done();
|
||||
assert.equal(deleteError, null);
|
||||
assert.equal(deleted, true);
|
||||
assert.ok(deleteResponse.isSuccessful);
|
||||
assert.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
done();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testInsertEntity: function (test) {
|
||||
test('InsertEntity', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.insertEntity(tableName, entity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.insertEntity(tableName, entity2, function (insertError2, insertEntity2, insertResponse2) {
|
||||
test.equal(insertError2, null);
|
||||
test.notEqual(insertEntity2, null);
|
||||
test.equal(insertResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError2, null);
|
||||
assert.notEqual(insertEntity2, null);
|
||||
assert.equal(insertResponse2.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
.from(tableName);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.notEqual(entries, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
test.equal(queryResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(queryError, null);
|
||||
assert.notEqual(entries, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
assert.equal(queryResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
test.ok(entries);
|
||||
assert.ok(entries);
|
||||
var entities = 0;
|
||||
entries.forEach(function (currentEntry) {
|
||||
if (currentEntry['PartitionKey'] === entity1['PartitionKey'] && currentEntry['RowKey'] === entity1['RowKey']) {
|
||||
entities += 1;
|
||||
|
||||
test.ok(currentEntry['etag']);
|
||||
test.equal(currentEntry['field'], entity1['field']);
|
||||
test.equal(currentEntry['otherfield'], entity1['otherfield']);
|
||||
test.equal(currentEntry['otherprops'], entity1['otherprops']);
|
||||
assert.ok(currentEntry['etag']);
|
||||
assert.equal(currentEntry['field'], entity1['field']);
|
||||
assert.equal(currentEntry['otherfield'], entity1['otherfield']);
|
||||
assert.equal(currentEntry['otherprops'], entity1['otherprops']);
|
||||
}
|
||||
else if (currentEntry['PartitionKey'] === entity2['PartitionKey'] && currentEntry['RowKey'] === entity2['RowKey']) {
|
||||
entities += 2;
|
||||
|
||||
test.ok(currentEntry['etag']);
|
||||
test.equal(currentEntry['boolValueTrue'], entity2['boolValueTrue']['#']);
|
||||
test.equal(currentEntry['boolValueFalse'], entity2['boolValueFalse']['#']);
|
||||
test.equal(currentEntry['intValue'], entity2['intValue']['#']);
|
||||
assert.ok(currentEntry['etag']);
|
||||
assert.equal(currentEntry['boolValueTrue'], entity2['boolValueTrue']['#']);
|
||||
assert.equal(currentEntry['boolValueFalse'], entity2['boolValueFalse']['#']);
|
||||
assert.equal(currentEntry['intValue'], entity2['intValue']['#']);
|
||||
|
||||
var date1 = new Date(currentEntry['dateValue']);
|
||||
var date2 = new Date(entity2['dateValue']['#']);
|
||||
test.ok(date1, date2);
|
||||
assert.ok(date1, date2);
|
||||
}
|
||||
});
|
||||
|
||||
test.equal(entities, 3);
|
||||
assert.equal(entities, 3);
|
||||
|
||||
tableQuery = TableQuery.select()
|
||||
.from(tableName)
|
||||
.whereKeys(entity1.PartitionKey, entity1.RowKey);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError2, tableEntries2, tableEntriesContinuation2, queryResponse2) {
|
||||
test.equal(queryError2, null);
|
||||
test.ok(queryResponse2.isSuccessful);
|
||||
test.equal(queryResponse2.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(queryError2, null);
|
||||
assert.ok(queryResponse2.isSuccessful);
|
||||
assert.equal(queryResponse2.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
test.ok(tableEntries2);
|
||||
assert.ok(tableEntries2);
|
||||
var newentities = 0;
|
||||
tableEntries2.forEach(function (newcurrentEntry) {
|
||||
|
||||
if (newcurrentEntry['PartitionKey'] === entity1['PartitionKey'] && newcurrentEntry['RowKey'] === entity1['RowKey']) {
|
||||
newentities += 1;
|
||||
|
||||
test.ok(newcurrentEntry['etag']);
|
||||
test.equal(newcurrentEntry['field'], entity1['field']);
|
||||
test.equal(newcurrentEntry['otherfield'], entity1['otherfield']);
|
||||
test.equal(newcurrentEntry['otherprops'], entity1['otherprops']);
|
||||
assert.ok(newcurrentEntry['etag']);
|
||||
assert.equal(newcurrentEntry['field'], entity1['field']);
|
||||
assert.equal(newcurrentEntry['otherfield'], entity1['otherfield']);
|
||||
assert.equal(newcurrentEntry['otherprops'], entity1['otherprops']);
|
||||
}
|
||||
});
|
||||
|
||||
test.equal(newentities, 1);
|
||||
assert.equal(newentities, 1);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testInsertEntityWithHtmlSpecialChars: function (test) {
|
||||
test('InsertEntityWithHtmlSpecialChars', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var newEntity = entity1;
|
||||
newEntity['field'] = 'XML <test>'; // this should work without breaking the XML
|
||||
|
||||
tableService.insertEntity(tableName, newEntity, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var tableQuery = TableQuery.select()
|
||||
.from(tableName)
|
||||
.whereKeys(newEntity.PartitionKey, newEntity.RowKey);
|
||||
|
||||
tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) {
|
||||
test.equal(queryError, null);
|
||||
test.notEqual(entries, null);
|
||||
test.ok(queryResponse.isSuccessful);
|
||||
test.ok(queryResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
assert.equal(queryError, null);
|
||||
assert.notEqual(entries, null);
|
||||
assert.ok(queryResponse.isSuccessful);
|
||||
assert.ok(queryResponse.statusCode, HttpConstants.HttpResponseCodes.OK_CODE);
|
||||
|
||||
test.equal(entries[0]['field'], 'XML <test>');
|
||||
test.done();
|
||||
assert.equal(entries[0]['field'], 'XML <test>');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testDeleteEntityWithoutEtag: function (test) {
|
||||
test('DeleteEntityWithoutEtag', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.insertEntity(tableName, entity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.deleteEntity(tableName, entity1, false, function (deleteError, deleted, deleteResponse) {
|
||||
test.equal(deleteError, null);
|
||||
test.equal(deleted, true);
|
||||
test.ok(deleteResponse.isSuccessful);
|
||||
test.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
assert.equal(deleteError, null);
|
||||
assert.equal(deleted, true);
|
||||
assert.ok(deleteResponse.isSuccessful);
|
||||
assert.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testDeleteEntityWithEtag: function (test) {
|
||||
test('DeleteEntityWithEtag', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
tableService.insertEntity(tableName, entity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
// Set a fake old etag
|
||||
entity1['etag'] = 'W/"datetime\'2009-05-27T12%3A15%3A15.3321531Z\'"';
|
||||
|
||||
// Delete forcing etag to be verified
|
||||
tableService.deleteEntity(tableName, entity1, { checkEtag: true }, function (deleteError, deleted, deleteResponse) {
|
||||
test.equal(deleteError.code, StorageErrorCodeStrings.UPDATE_CONDITION_NOT_SATISFIED);
|
||||
test.equal(deleted, false);
|
||||
test.equal(deleteResponse.isSuccessful, false);
|
||||
test.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.PRECONDITION_FAILED_CODE);
|
||||
assert.equal(deleteError.code, StorageErrorCodeStrings.UPDATE_CONDITION_NOT_SATISFIED);
|
||||
assert.equal(deleted, false);
|
||||
assert.equal(deleteResponse.isSuccessful, false);
|
||||
assert.equal(deleteResponse.statusCode, HttpConstants.HttpResponseCodes.PRECONDITION_FAILED_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testUpdateEntityWithoutEtag: function (test) {
|
||||
test('UpdateEntityWithoutEtag', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
var newField = 'value';
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var newEntity1 = entity1;
|
||||
tableService.insertEntity(tableName, newEntity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
var originalEtag = newEntity1['etag'];
|
||||
|
||||
newEntity1['otherfield'] = newField;
|
||||
|
||||
tableService.updateEntity(tableName, newEntity1, false, function (updateError2, updateEntity2, updateResponse2) {
|
||||
test.equal(updateError2, null);
|
||||
test.notEqual(updateEntity2, null);
|
||||
test.ok(updateResponse2.isSuccessful);
|
||||
test.equal(updateResponse2.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
test.notEqual(newEntity1.etag, originalEtag);
|
||||
assert.equal(updateError2, null);
|
||||
assert.notEqual(updateEntity2, null);
|
||||
assert.ok(updateResponse2.isSuccessful);
|
||||
assert.equal(updateResponse2.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
assert.notEqual(newEntity1.etag, originalEtag);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testUpdateEntityWithEtag: function (test) {
|
||||
test('UpdateEntityWithEtag', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
var newField = 'value';
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var newEntity1 = entity1;
|
||||
tableService.insertEntity(tableName, newEntity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
newEntity1['otherfield'] = newField;
|
||||
|
||||
|
@ -480,64 +479,64 @@ module.exports = testCase(
|
|||
newEntity1['etag'] = 'W/"datetime\'2009-05-27T12%3A15%3A15.3321531Z\'"';
|
||||
|
||||
tableService.updateEntity(tableName, newEntity1, { checkEtag: true }, function (updateError, updateEntity, updateResponse) {
|
||||
test.equal(updateError.code, StorageErrorCodeStrings.CONDITION_NOT_MET);
|
||||
test.equal(updateEntity, null);
|
||||
test.equal(updateResponse.isSuccessful, false);
|
||||
test.equal(updateResponse.statusCode, HttpConstants.HttpResponseCodes.PRECONDITION_FAILED_CODE);
|
||||
assert.equal(updateError.code, StorageErrorCodeStrings.CONDITION_NOT_MET);
|
||||
assert.equal(updateEntity, null);
|
||||
assert.equal(updateResponse.isSuccessful, false);
|
||||
assert.equal(updateResponse.statusCode, HttpConstants.HttpResponseCodes.PRECONDITION_FAILED_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testMergeEntityWithoutEtag: function (test) {
|
||||
test('MergeEntityWithoutEtag', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
var newField = 'value';
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var newEntity1 = entity1;
|
||||
tableService.insertEntity(tableName, newEntity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
insertEntity['otherfield'] = newField;
|
||||
|
||||
tableService.mergeEntity(tableName, newEntity1, false, function (mergeError, mergeEntity, mergeResponse) {
|
||||
test.equal(mergeError, null);
|
||||
test.notEqual(mergeEntity, null);
|
||||
test.ok(mergeResponse.isSuccessful);
|
||||
test.equal(mergeResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
assert.equal(mergeError, null);
|
||||
assert.notEqual(mergeEntity, null);
|
||||
assert.ok(mergeResponse.isSuccessful);
|
||||
assert.equal(mergeResponse.statusCode, HttpConstants.HttpResponseCodes.NO_CONTENT_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testMergeEntityWithEtag: function (test) {
|
||||
test('MergeEntityWithEtag', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
var newField = 'value';
|
||||
|
||||
tableService.createTable(tableName, function (createError, table, createResponse) {
|
||||
test.equal(createError, null);
|
||||
test.notEqual(table, null);
|
||||
test.ok(createResponse.isSuccessful);
|
||||
test.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(createError, null);
|
||||
assert.notEqual(table, null);
|
||||
assert.ok(createResponse.isSuccessful);
|
||||
assert.equal(createResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
var newEntity1 = entity1;
|
||||
tableService.insertEntity(tableName, newEntity1, function (insertError, insertEntity, insertResponse) {
|
||||
test.equal(insertError, null);
|
||||
test.notEqual(insertEntity, null);
|
||||
test.ok(insertResponse.isSuccessful);
|
||||
test.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
assert.equal(insertError, null);
|
||||
assert.notEqual(insertEntity, null);
|
||||
assert.ok(insertResponse.isSuccessful);
|
||||
assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.CREATED_CODE);
|
||||
|
||||
newEntity1['otherfield'] = newField;
|
||||
|
||||
|
@ -545,22 +544,22 @@ module.exports = testCase(
|
|||
newEntity1['etag'] = 'W/"datetime\'2009-05-27T12%3A15%3A15.3321531Z\'"';
|
||||
|
||||
tableService.mergeEntity(tableName, newEntity1, { checkEtag: true }, function (mergeError, mergeEntity, mergeResponse) {
|
||||
test.equal(mergeError.code, StorageErrorCodeStrings.UPDATE_CONDITION_NOT_SATISFIED);
|
||||
test.equal(mergeEntity, null);
|
||||
test.equal(mergeResponse.isSuccessful, false);
|
||||
test.equal(mergeResponse.statusCode, HttpConstants.HttpResponseCodes.PRECONDITION_FAILED_CODE);
|
||||
assert.equal(mergeError.code, StorageErrorCodeStrings.UPDATE_CONDITION_NOT_SATISFIED);
|
||||
assert.equal(mergeEntity, null);
|
||||
assert.equal(mergeResponse.isSuccessful, false);
|
||||
assert.equal(mergeResponse.statusCode, HttpConstants.HttpResponseCodes.PRECONDITION_FAILED_CODE);
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testInsertOrReplaceEntity: function (test) {
|
||||
test('InsertOrReplaceEntity', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (error) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
var entity = {
|
||||
PartitionKey: '1',
|
||||
|
@ -571,38 +570,38 @@ module.exports = testCase(
|
|||
|
||||
// Should perform an insert
|
||||
tableService.insertOrReplaceEntity(tableName, entity, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
// change value of field2
|
||||
entity.field2 = 2;
|
||||
|
||||
// should perform an update
|
||||
tableService.insertOrReplaceEntity(tableName, entity, function (error3) {
|
||||
test.equal(error3, null);
|
||||
assert.equal(error3, null);
|
||||
|
||||
tableService.queryEntity(tableName, entity.PartitionKey, entity.RowKey, function (error4, entityResult) {
|
||||
test.equal(error4, null);
|
||||
assert.equal(error4, null);
|
||||
|
||||
test.notEqual(entityResult, null);
|
||||
assert.notEqual(entityResult, null);
|
||||
if (entityResult) {
|
||||
test.equal(entityResult.PartitionKey, entity.PartitionKey);
|
||||
test.equal(entityResult.RowKey, entity.RowKey);
|
||||
test.equal(entityResult.field1, entity.field1);
|
||||
test.equal(entityResult.field2, entity.field2);
|
||||
assert.equal(entityResult.PartitionKey, entity.PartitionKey);
|
||||
assert.equal(entityResult.RowKey, entity.RowKey);
|
||||
assert.equal(entityResult.field1, entity.field1);
|
||||
assert.equal(entityResult.field2, entity.field2);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testInsertOrMerge: function (test) {
|
||||
test('InsertOrMerge', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (error) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
var entity = {
|
||||
PartitionKey: '1',
|
||||
|
@ -613,39 +612,39 @@ module.exports = testCase(
|
|||
|
||||
// Should perform an insert
|
||||
tableService.insertOrMergeEntity(tableName, entity, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
// Add a new field
|
||||
entity.field3 = 2;
|
||||
|
||||
// should perform a merge
|
||||
tableService.insertOrMergeEntity(tableName, entity, function (error3) {
|
||||
test.equal(error3, null);
|
||||
assert.equal(error3, null);
|
||||
|
||||
tableService.queryEntity(tableName, entity.PartitionKey, entity.RowKey, function (error4, entityResult) {
|
||||
test.equal(error4, null);
|
||||
assert.equal(error4, null);
|
||||
|
||||
test.notEqual(entityResult, null);
|
||||
assert.notEqual(entityResult, null);
|
||||
if (entityResult) {
|
||||
test.equal(entityResult.PartitionKey, entity.PartitionKey);
|
||||
test.equal(entityResult.RowKey, entity.RowKey);
|
||||
test.equal(entityResult.field1, entity.field1);
|
||||
test.equal(entityResult.field2, entity.field2);
|
||||
test.equal(entityResult.field3, entity.field3);
|
||||
assert.equal(entityResult.PartitionKey, entity.PartitionKey);
|
||||
assert.equal(entityResult.RowKey, entity.RowKey);
|
||||
assert.equal(entityResult.field1, entity.field1);
|
||||
assert.equal(entityResult.field2, entity.field2);
|
||||
assert.equal(entityResult.field3, entity.field3);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
testInsertEntityEmptyField: function (test) {
|
||||
test('InsertEntityEmptyField', function (done) {
|
||||
var tableName = testutil.generateId(tablePrefix, tableNames, tabletestutil.isMocked);
|
||||
|
||||
tableService.createTable(tableName, function (error) {
|
||||
test.equal(error, null);
|
||||
assert.equal(error, null);
|
||||
|
||||
var entity = {
|
||||
PartitionKey: '1',
|
||||
|
@ -658,24 +657,24 @@ module.exports = testCase(
|
|||
|
||||
// Should perform an insert
|
||||
tableService.insertOrMergeEntity(tableName, entity, function (error2) {
|
||||
test.equal(error2, null);
|
||||
assert.equal(error2, null);
|
||||
|
||||
tableService.queryEntity(tableName, entity.PartitionKey, entity.RowKey, function (error4, entityResult) {
|
||||
test.equal(error4, null);
|
||||
assert.equal(error4, null);
|
||||
|
||||
test.notEqual(entityResult, null);
|
||||
assert.notEqual(entityResult, null);
|
||||
if (entityResult) {
|
||||
test.equal(entityResult.PartitionKey, entity.PartitionKey);
|
||||
test.equal(entityResult.RowKey, entity.RowKey);
|
||||
test.equal(entityResult.field1, entity.field1);
|
||||
test.equal(entityResult.emptyField1, entity.emptyField1);
|
||||
test.equal(entityResult.emptyField2, entity.emptyField2);
|
||||
test.equal(entityResult.nonEmptyField3, entity.nonEmptyField3);
|
||||
assert.equal(entityResult.PartitionKey, entity.PartitionKey);
|
||||
assert.equal(entityResult.RowKey, entity.RowKey);
|
||||
assert.equal(entityResult.field1, entity.field1);
|
||||
assert.equal(entityResult.emptyField1, entity.emptyField1);
|
||||
assert.equal(entityResult.emptyField2, entity.emptyField2);
|
||||
assert.equal(entityResult.nonEmptyField3, entity.nonEmptyField3);
|
||||
}
|
||||
|
||||
test.done();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,6 @@ services/table/tableservice-batch-tests.js
|
|||
services/table/tableservice-tablequery-tests.js
|
||||
services/table/tableservice-tests.js
|
||||
util/atomhandler-tests.js
|
||||
util/base64-tests.js
|
||||
util/iso8061date-tests.js
|
||||
util/util-tests.js
|
||||
azure-tests.js
|
|
@ -13,24 +13,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var AtomHandler = require('../../lib/util/atomhandler');
|
||||
var ISO8061Date = require('../../lib/util/iso8061date');
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = testCase({
|
||||
setUp: function (callback) {
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function (callback) {
|
||||
// clean up.
|
||||
callback();
|
||||
},
|
||||
|
||||
testSerialize: function (test) {
|
||||
suite('atomhandler-tests', function () {
|
||||
test('Serialize', function (done) {
|
||||
var atomHandler = new AtomHandler('m', 'd');
|
||||
|
||||
var entity = {
|
||||
|
@ -55,7 +46,7 @@ module.exports = testCase({
|
|||
|
||||
var res = atomHandler.serialize(entity);
|
||||
|
||||
test.ok(res.indexOf(
|
||||
assert.ok(res.indexOf(
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"
|
||||
+ "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
|
||||
+ "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" "
|
||||
|
@ -63,7 +54,7 @@ module.exports = testCase({
|
|||
+ "<title/>"
|
||||
+ "<updated>") !== -1);
|
||||
|
||||
test.ok(res.indexOf(
|
||||
assert.ok(res.indexOf(
|
||||
"</updated>"
|
||||
+ "<author>"
|
||||
+ "<name/>"
|
||||
|
@ -79,6 +70,6 @@ module.exports = testCase({
|
|||
+ "</content>"
|
||||
+ "</entry>") !== -1);
|
||||
|
||||
test.done();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,15 +31,15 @@ module.exports = testCase(
|
|||
callback();
|
||||
},
|
||||
|
||||
testEncode64: function (test) {
|
||||
testEncode64: function (done) {
|
||||
var enc = Base64.encode64(testBase64Text);
|
||||
test.equal(enc, testBase64Coded);
|
||||
test.done();
|
||||
assert.equal(enc, testBase64Coded);
|
||||
done();
|
||||
},
|
||||
|
||||
testDecode64: function (test) {
|
||||
testDecode64: function (done) {
|
||||
var dec = Base64.decode64(testBase64Coded);
|
||||
test.equal(dec, testBase64Text);
|
||||
test.done();
|
||||
assert.equal(dec, testBase64Text);
|
||||
done();
|
||||
}
|
||||
});
|
|
@ -13,67 +13,56 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var ISO8061Date = require('../../lib/util/iso8061date');
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
callback();
|
||||
},
|
||||
|
||||
tearDown: function (callback) {
|
||||
// clean up
|
||||
callback();
|
||||
},
|
||||
|
||||
testParse: function (test) {
|
||||
suite('iso8061date-tests', function () {
|
||||
test('Parse', function (done) {
|
||||
var datetime = new Date(Date.UTC(2011, 6, 17, 14, 0, 23, 270));
|
||||
var datetimeAtom = "2011-07-17T14:00:23.270Z";
|
||||
var parsed = ISO8061Date.parse(datetimeAtom);
|
||||
test.deepEqual(parsed, datetime);
|
||||
test.done();
|
||||
},
|
||||
assert.deepEqual(parsed, datetime);
|
||||
done();
|
||||
});
|
||||
|
||||
testParseLongTimestamp: function (test) {
|
||||
test('ParseLongTimestamp', function (done) {
|
||||
var datetime = new Date(Date.UTC(2011, 6, 17, 14, 0, 23, 270));
|
||||
var datetimeAtom = "2011-07-17T14:00:23.2701234Z";
|
||||
var parsed = ISO8061Date.parse(datetimeAtom);
|
||||
test.deepEqual(parsed, datetime);
|
||||
test.done();
|
||||
},
|
||||
assert.deepEqual(parsed, datetime);
|
||||
done();
|
||||
});
|
||||
|
||||
testParseLongTimestampWithRounding: function(test) {
|
||||
test('ParseLongTimestampWithRounding', function (done) {
|
||||
var datetime = new Date(Date.UTC(2011, 6, 17, 14, 0, 23, 270));
|
||||
var datetimeAtom = "2011-07-17T14:00:23.26993Z";
|
||||
var parsed = ISO8061Date.parse(datetimeAtom);
|
||||
test.deepEqual(parsed, datetime);
|
||||
test.done();
|
||||
},
|
||||
assert.deepEqual(parsed, datetime);
|
||||
done();
|
||||
});
|
||||
|
||||
testParseShortMillis: function (test) {
|
||||
test('ParseShortMillis', function (done) {
|
||||
var datetime = new Date(Date.UTC(2011, 6, 17, 14, 0, 23, 200));
|
||||
var datetimeAtom = "2011-07-17T14:00:23.2Z";
|
||||
var parsed = ISO8061Date.parse(datetimeAtom);
|
||||
test.deepEqual(parsed, datetime);
|
||||
test.done();
|
||||
},
|
||||
assert.deepEqual(parsed, datetime);
|
||||
done();
|
||||
});
|
||||
|
||||
testParsePaddedShortMillis: function (test) {
|
||||
test('ParsePaddedShortMillis', function (done) {
|
||||
var datetime = new Date(Date.UTC(2011, 6, 17, 14, 0, 23, 3));
|
||||
var datetimeAtom = "2011-07-17T14:00:23.003Z";
|
||||
var parsed = ISO8061Date.parse(datetimeAtom);
|
||||
test.deepEqual(parsed, datetime);
|
||||
test.done();
|
||||
},
|
||||
assert.deepEqual(parsed, datetime);
|
||||
done();
|
||||
});
|
||||
|
||||
testFormat: function (test) {
|
||||
test('Format', function (done) {
|
||||
var datetime = Date.UTC(2011, 6, 17, 14, 0, 23, 270);
|
||||
var datetimeAtom = "2011-07-17T14:00:23.270Z";
|
||||
var strdate = ISO8061Date.format(new Date(datetime));
|
||||
test.equal(strdate, datetimeAtom);
|
||||
test.done();
|
||||
}
|
||||
|
||||
assert.equal(strdate, datetimeAtom);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -78,11 +78,11 @@ exports.tearDownTest = function (testObject, serviceBusService, testPrefix, call
|
|||
|
||||
var checkValue = function( test, value, optionValue) {
|
||||
if (optionValue) {
|
||||
test.equal(value, optionValue);
|
||||
assert.equal(value, optionValue);
|
||||
}
|
||||
};
|
||||
|
||||
exports.validateQueue = function( testObject, queueName, queueOptions, queue) {
|
||||
exports.validateQueue = function(testObject, queueName, queueOptions, queue) {
|
||||
testObject.notEqual(queue, null);
|
||||
if (queue) {
|
||||
testObject.equal(queue.QueueName, queueName);
|
||||
|
@ -94,13 +94,13 @@ exports.validateQueue = function( testObject, queueName, queueOptions, queue) {
|
|||
checkValue(testObject, queue.DuplicateDetectionHistoryTimeWindow, queueOptions.DuplicateDetectionHistoryTimeWindow);
|
||||
checkValue(testObject, queue.MaxSizeInMegabytes, queueOptions.MaxSizeInMegabytes);
|
||||
};
|
||||
};
|
||||
|
||||
exports.checkNullParameter = function( callback) {
|
||||
assert.throws(
|
||||
function() {
|
||||
exports.checkNullParameter = function (callback) {
|
||||
assert.throws(
|
||||
function () {
|
||||
callback();
|
||||
},
|
||||
},
|
||||
/name must be a non empty string/
|
||||
);
|
||||
};
|
||||
};
|
|
@ -13,143 +13,133 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
var assert = require('assert');
|
||||
|
||||
var util = require('../../lib/util/util');
|
||||
|
||||
module.exports = testCase(
|
||||
{
|
||||
setUp: function (callback) {
|
||||
callback();
|
||||
},
|
||||
suite('util-tests', function() {
|
||||
test('should be an empty object', function (done) {
|
||||
assert.equal(util.objectIsEmpty(null), true);
|
||||
assert.equal(util.objectIsEmpty({}), true);
|
||||
assert.equal(util.objectIsEmpty({ a: '1' }), false);
|
||||
assert.equal(util.objectIsEmpty({ a: '1', b: '2' }), false);
|
||||
|
||||
tearDown: function (callback) {
|
||||
// clean up
|
||||
callback();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testObjectIsEmpty: function (test) {
|
||||
test.equal(util.objectIsEmpty(null), true);
|
||||
test.equal(util.objectIsEmpty({}), true);
|
||||
test.equal(util.objectIsEmpty({ a: '1' }), false);
|
||||
test.equal(util.objectIsEmpty({ a: '1', b: '2' }), false);
|
||||
test('should be a string', function (done) {
|
||||
assert.equal(util.objectIsString(''), true);
|
||||
assert.equal(util.objectIsString('hi'), true);
|
||||
assert.equal(util.objectIsString(null), false);
|
||||
assert.equal(util.objectIsString({}), false);
|
||||
assert.equal(util.objectIsString({ a: '1' }), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testObjectIsString: function (test) {
|
||||
test.equal(util.objectIsString(''), true);
|
||||
test.equal(util.objectIsString('hi'), true);
|
||||
test.equal(util.objectIsString(null), false);
|
||||
test.equal(util.objectIsString({}), false);
|
||||
test.equal(util.objectIsString({ a: '1' }), false);
|
||||
test('should be an empty string', function (done) {
|
||||
assert.equal(util.stringIsEmpty(''), true);
|
||||
assert.equal(util.stringIsEmpty(null), true);
|
||||
assert.equal(util.stringIsEmpty(undefined), true);
|
||||
assert.equal(util.stringIsEmpty('a'), false);
|
||||
assert.equal(util.stringIsEmpty(' '), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testStringIsEmpty: function (test) {
|
||||
test.equal(util.stringIsEmpty(''), true);
|
||||
test.equal(util.stringIsEmpty(null), true);
|
||||
test.equal(util.stringIsEmpty(undefined), true);
|
||||
test.equal(util.stringIsEmpty('a'), false);
|
||||
test.equal(util.stringIsEmpty(' '), false);
|
||||
test('should start with', function (done) {
|
||||
assert.equal(util.stringStartsWith('test', 't'), true);
|
||||
assert.equal(util.stringStartsWith('test', 'e'), false);
|
||||
assert.equal(util.stringStartsWith('test', ''), true);
|
||||
assert.equal(util.stringStartsWith('test', null), true);
|
||||
assert.equal(util.stringStartsWith('test', 'T'), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testStringStartsWith: function (test) {
|
||||
test.equal(util.stringStartsWith('test', 't'), true);
|
||||
test.equal(util.stringStartsWith('test', 'e'), false);
|
||||
test.equal(util.stringStartsWith('test', ''), true);
|
||||
test.equal(util.stringStartsWith('test', null), true);
|
||||
test.equal(util.stringStartsWith('test', 'T'), false);
|
||||
test('should end with', function (done) {
|
||||
assert.equal(util.stringEndsWith('test', 't'), true);
|
||||
assert.equal(util.stringEndsWith('test', 'e'), false);
|
||||
assert.equal(util.stringEndsWith('test', ''), true);
|
||||
assert.equal(util.stringEndsWith('test', null), true);
|
||||
assert.equal(util.stringEndsWith('test', 'T'), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testStringEndsWith: function (test) {
|
||||
test.equal(util.stringEndsWith('test', 't'), true);
|
||||
test.equal(util.stringEndsWith('test', 'e'), false);
|
||||
test.equal(util.stringEndsWith('test', ''), true);
|
||||
test.equal(util.stringEndsWith('test', null), true);
|
||||
test.equal(util.stringEndsWith('test', 'T'), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
|
||||
testStringIsInt: function (test) {
|
||||
test('should be int', function (done) {
|
||||
// positives
|
||||
test.equal(util.stringIsInt('1'), true);
|
||||
test.equal(util.stringIsInt('1asd'), false);
|
||||
test.equal(util.stringIsInt('asd1'), false);
|
||||
test.equal(util.stringIsInt('1.23'), false);
|
||||
assert.equal(util.stringIsInt('1'), true);
|
||||
assert.equal(util.stringIsInt('1asd'), false);
|
||||
assert.equal(util.stringIsInt('asd1'), false);
|
||||
assert.equal(util.stringIsInt('1.23'), false);
|
||||
|
||||
// negatives
|
||||
test.equal(util.stringIsInt('-1'), true);
|
||||
test.equal(util.stringIsInt('-1asd'), false);
|
||||
test.equal(util.stringIsInt('-asd1'), false);
|
||||
test.equal(util.stringIsInt('-1.23'), false);
|
||||
assert.equal(util.stringIsInt('-1'), true);
|
||||
assert.equal(util.stringIsInt('-1asd'), false);
|
||||
assert.equal(util.stringIsInt('-asd1'), false);
|
||||
assert.equal(util.stringIsInt('-1.23'), false);
|
||||
|
||||
// nulls
|
||||
test.equal(util.stringIsInt(null), false);
|
||||
test.equal(util.stringIsInt(), false);
|
||||
assert.equal(util.stringIsInt(null), false);
|
||||
assert.equal(util.stringIsInt(), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testStringIsFloat: function (test) {
|
||||
test('should be float', function (done) {
|
||||
// positives
|
||||
test.equal(util.stringIsFloat('1'), false);
|
||||
test.equal(util.stringIsFloat('1.'), false);
|
||||
test.equal(util.stringIsFloat('1.0'), false);
|
||||
test.equal(util.stringIsFloat('1.1'), true);
|
||||
test.equal(util.stringIsFloat('1.0a'), false);
|
||||
test.equal(util.stringIsFloat('1a'), false);
|
||||
assert.equal(util.stringIsFloat('1'), false);
|
||||
assert.equal(util.stringIsFloat('1.'), false);
|
||||
assert.equal(util.stringIsFloat('1.0'), false);
|
||||
assert.equal(util.stringIsFloat('1.1'), true);
|
||||
assert.equal(util.stringIsFloat('1.0a'), false);
|
||||
assert.equal(util.stringIsFloat('1a'), false);
|
||||
|
||||
// negatives
|
||||
test.equal(util.stringIsFloat('-1'), false);
|
||||
test.equal(util.stringIsFloat('-1.'), false);
|
||||
test.equal(util.stringIsFloat('-1.0'), false);
|
||||
test.equal(util.stringIsFloat('-1.1'), true);
|
||||
test.equal(util.stringIsFloat('-1.0a'), false);
|
||||
test.equal(util.stringIsFloat('-1a'), false);
|
||||
assert.equal(util.stringIsFloat('-1'), false);
|
||||
assert.equal(util.stringIsFloat('-1.'), false);
|
||||
assert.equal(util.stringIsFloat('-1.0'), false);
|
||||
assert.equal(util.stringIsFloat('-1.1'), true);
|
||||
assert.equal(util.stringIsFloat('-1.0a'), false);
|
||||
assert.equal(util.stringIsFloat('-1a'), false);
|
||||
|
||||
// nulls
|
||||
test.equal(util.stringIsFloat(null), false);
|
||||
test.equal(util.stringIsFloat(), false);
|
||||
assert.equal(util.stringIsFloat(null), false);
|
||||
assert.equal(util.stringIsFloat(), false);
|
||||
|
||||
test.done();
|
||||
},
|
||||
done();
|
||||
});
|
||||
|
||||
testStringIsNumber: function (test) {
|
||||
test('should be a number', function (done) {
|
||||
// int positives
|
||||
test.equal(util.stringIsNumber('1'), true);
|
||||
test.equal(util.stringIsNumber('1asd'), false);
|
||||
test.equal(util.stringIsNumber('asd1'), false);
|
||||
assert.equal(util.stringIsNumber('1'), true);
|
||||
assert.equal(util.stringIsNumber('1asd'), false);
|
||||
assert.equal(util.stringIsNumber('asd1'), false);
|
||||
|
||||
// int negatives
|
||||
test.equal(util.stringIsNumber('-1'), true);
|
||||
test.equal(util.stringIsNumber('-1asd'), false);
|
||||
test.equal(util.stringIsNumber('-asd1'), false);
|
||||
assert.equal(util.stringIsNumber('-1'), true);
|
||||
assert.equal(util.stringIsNumber('-1asd'), false);
|
||||
assert.equal(util.stringIsNumber('-asd1'), false);
|
||||
|
||||
// float positives
|
||||
test.equal(util.stringIsNumber('1.'), true);
|
||||
test.equal(util.stringIsNumber('1.0'), true);
|
||||
test.equal(util.stringIsNumber('1.1'), true);
|
||||
test.equal(util.stringIsNumber('1.0a'), false);
|
||||
test.equal(util.stringIsNumber('1a'), false);
|
||||
assert.equal(util.stringIsNumber('1.'), true);
|
||||
assert.equal(util.stringIsNumber('1.0'), true);
|
||||
assert.equal(util.stringIsNumber('1.1'), true);
|
||||
assert.equal(util.stringIsNumber('1.0a'), false);
|
||||
assert.equal(util.stringIsNumber('1a'), false);
|
||||
|
||||
// float negatives
|
||||
test.equal(util.stringIsNumber('-1.'), true);
|
||||
test.equal(util.stringIsNumber('-1.0'), true);
|
||||
test.equal(util.stringIsNumber('-1.1'), true);
|
||||
test.equal(util.stringIsNumber('-1.0a'), false);
|
||||
test.equal(util.stringIsNumber('-1a'), false);
|
||||
assert.equal(util.stringIsNumber('-1.'), true);
|
||||
assert.equal(util.stringIsNumber('-1.0'), true);
|
||||
assert.equal(util.stringIsNumber('-1.1'), true);
|
||||
assert.equal(util.stringIsNumber('-1.0a'), false);
|
||||
assert.equal(util.stringIsNumber('-1a'), false);
|
||||
|
||||
// nulls
|
||||
test.equal(util.stringIsFloat(null), false);
|
||||
test.equal(util.stringIsFloat(), false);
|
||||
assert.equal(util.stringIsFloat(null), false);
|
||||
assert.equal(util.stringIsFloat(), false);
|
||||
|
||||
test.done();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
|
@ -13,8 +13,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var testCase = require('nodeunit').testCase;
|
||||
|
||||
var util = require('../../lib/util/util');
|
||||
|
||||
var exports = module.exports;
|
||||
|
|
Загрузка…
Ссылка в новой задаче