Permalink
Browse files

adding more UT

  • Loading branch information...
1 parent 501720b commit 3aa0fcba9245e259aa780c64e157adc8121554c5 Andre Rodrigues committed Oct 12, 2012
View
4 lib/services/core/servicesettings.js
@@ -120,8 +120,8 @@ exports.setting = function (name) {
return true;
}
- // Check to find if the $settingValue is valid or not.
- for (var index = 0; index < validValues.length; validValues++) {
+ // Check to find if the settingValue is valid or not.
+ for (var index = 0; index < validValues.length; index++) {
if (settingValue.toString() == validValues[index].toString()) {
// SettingValue is found in valid values set, succeed.
return true;
View
12 lib/services/core/storageservicesettings.js
@@ -151,31 +151,31 @@ StorageServiceSettings._getDefaultServiceEndpoint = function (settings, dns) {
* @return {StorageServiceSettings}
*/
StorageServiceSettings._createStorageServiceSettings = function (settings, blobEndpointUri, queueEndpointUri, tableEndpointUri) {
- blobEndpointUri = util.tryGetValueInsensitive(
+ var blobEndpointUri = util.tryGetValueInsensitive(
ConnectionStringKeys.BLOB_ENDPOINT_NAME,
settings,
blobEndpointUri
);
- queueEndpointUri = util.tryGetValueInsensitive(
+ var queueEndpointUri = util.tryGetValueInsensitive(
ConnectionStringKeys.QUEUE_ENDPOINT_NAME,
settings,
queueEndpointUri
);
- tableEndpointUri = util.tryGetValueInsensitive(
+ var tableEndpointUri = util.tryGetValueInsensitive(
ConnectionStringKeys.TABLE_ENDPOINT_NAME,
settings,
tableEndpointUri
);
- accountName = util.tryGetValueInsensitive(
+ var accountName = util.tryGetValueInsensitive(
ConnectionStringKeys.ACCOUNT_NAME_NAME,
settings
);
- accountKey = util.tryGetValueInsensitive(
- ConncetionStringKeys.ACCOUNT_KEY_NAME,
+ var accountKey = util.tryGetValueInsensitive(
+ ConnectionStringKeys.ACCOUNT_KEY_NAME,
settings
);
View
23 test/services/core/storageservicesettings-tests.js
@@ -14,6 +14,7 @@
*/
var should = require('should');
+var url = require('url');
var testutil = require('../../util/util');
var azure = testutil.libRequire('azure');
@@ -84,6 +85,28 @@ suite('storageservicesettings-tests', function () {
}).should.throw('The provided connection string does not have complete configuration settings.');
});
+ test('testCreateFromConnectionStringWithAutomatic', function () {
+ // Setup
+ var protocol = 'https';
+ var expectedName = 'mytestaccount';
+ var expectedKey = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
+ var connectionString = 'DefaultEndpointsProtocol=' + protocol + ';AccountName=' + expectedName + ';AccountKey=' + expectedKey;
+ var expectedBlobEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.BLOB_BASE_DNS_NAME });
+ var expectedQueueEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.QUEUE_BASE_DNS_NAME });
+ var expectedTableEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.TABLE_BASE_DNS_NAME });
+
+ // Test
+ var actual = StorageServiceSettings.createFromConnectionString(connectionString);
+
+ // Assert
+ actual._name.should.equal(expectedName);
+ actual._key.should.equal(expectedKey);
+ actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
+ actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
+ actual._tableEndpointUri.should.equal(expectedTableEndpoint);
+ });
+
+
test('getDevelopmentStorageAccount', function () {
var developmentStorageAccount = StorageServiceSettings._getDevelopmentStorageAccount();

0 comments on commit 3aa0fcb

Please sign in to comment.