Permalink
Browse files

Adding UT

  • Loading branch information...
1 parent ed21c48 commit ea1efbccce7eb137c3b8f75aad3b7ed9882cbdf8 Andre Rodrigues committed Oct 24, 2012
Showing with 129 additions and 14 deletions.
  1. +11 −6 lib/cli/commands/siteconfig.js
  2. +8 −3 lib/cli/commands/siteconfig_.js
  3. +109 −0 test/cli/commands/cli.siteconfig-tests.js
  4. +1 −5 test/clitestlist.txt
@@ -84,16 +84,21 @@ exports.init = function(cli) {
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 6, function __$__1() {
return site.doSiteConfigGet(context, __cb(_, __frame, 10, 31, function ___(__0, __1) { siteConfigurations = __1;
- if ((siteConfigurations.AppSettings.length > 0)) {
- log.table(siteConfigurations.AppSettings, function(row, item) {
- row.cell("Name", item.GeoRegion); }); }
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ if (siteConfigurations.AppSettings.NameValuePair.Name) {
+ siteConfigurations.AppSettings.NameValuePair = [siteConfigurations.AppSettings.NameValuePair,]; } ;
+
+
+ log.table(siteConfigurations.AppSettings.NameValuePair, function(row, item) {
+ row.cell("Name", item.Name);
+ row.cell("Value", item.Value); }); }
else {
log.info("No app settings defined yet. You can define app settings using \"azure site config set <name>=<value>."); } ; _(); }, true)); }, true)); }); });
- siteConfig.command("add <keyvaluepair> [name]").usage("[options] <keyvaluepair> [name]").description("Adds an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __2(keyvaluepair, name, options, _) { var context, settings, siteConfigurations, setting; var __frame = { name: "__2", line: 100 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
+ siteConfig.command("add <keyvaluepair> [name]").usage("[options] <keyvaluepair> [name]").description("Adds an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __2(keyvaluepair, name, options, _) { var context, settings, siteConfigurations, setting; var __frame = { name: "__2", line: 105 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
@@ -138,7 +143,7 @@ exports.init = function(cli) {
return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 38, 6, _, true)); }, true)); }, true)); }); });
- siteConfig.command("clear <key> [name]").usage("[options] <key> [name]").description("Clears an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __3(key, name, options, _) { var context, siteConfigurations, found, settings, i; var __frame = { name: "__3", line: 145 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
+ siteConfig.command("clear <key> [name]").usage("[options] <key> [name]").description("Clears an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __3(key, name, options, _) { var context, siteConfigurations, found, settings, i; var __frame = { name: "__3", line: 150 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
@@ -180,7 +185,7 @@ exports.init = function(cli) {
- siteConfig.command("get <key> [name]").usage("[options] <key> [name]").description("Gets an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __4(key, name, options, _) { var context, siteConfigurations, found, settings, i; var __frame = { name: "__4", line: 187 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
+ siteConfig.command("get <key> [name]").usage("[options] <key> [name]").description("Gets an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __4(key, name, options, _) { var context, siteConfigurations, found, settings, i; var __frame = { name: "__4", line: 192 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
@@ -84,9 +84,14 @@ exports.init = function (cli) {
site.lookupSiteNameAndWebSpace(context, _);
var siteConfigurations = site.doSiteConfigGet(context, _);
- if (siteConfigurations.AppSettings.length > 0) {
- log.table(siteConfigurations.AppSettings, function (row, item) {
- row.cell('Name', item.GeoRegion);
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ if (siteConfigurations.AppSettings.NameValuePair.Name) {
+ siteConfigurations.AppSettings.NameValuePair = [ siteConfigurations.AppSettings.NameValuePair ];
+ }
+
+ log.table(siteConfigurations.AppSettings.NameValuePair, function (row, item) {
+ row.cell('Name', item.Name);
+ row.cell('Value', item.Value);
});
} else {
log.info('No app settings defined yet. You can define app settings using "azure site config set <name>=<value>.');
@@ -0,0 +1,109 @@
+/**
+* Copyright 2012 Microsoft Corporation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+* Copyright 2012 Microsoft Corporation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var should = require('should');
+var cli = require('../cli');
+var capture = require('../util').capture;
+
+suite('cli', function(){
+ suite('siteconfig', function() {
+ test('siteconfig list', function(done) {
+ var siteName = 'cliuttestsiteconfig1';
+
+ // Create site
+ var cmd = ('node cli.js site create ' + siteName + ' --json --location').split(' ');
+ cmd.push('East US');
+
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ // List sites
+ cmd = ('node cli.js site config list ' + siteName + ' --json ').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ // there should be not settings yet as the site was just created
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ // add a setting
+ var cmd = ('node cli.js site config add mysetting=myvalue ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ cmd = 'node cli.js site config list --json'.split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ var settingsList = JSON.parse(result.text);
+
+ // Listing should return 1 setting now
+ settingsList.length.should.equal(1);
+
+ // add another setting
+ var cmd = ('node cli.js site config add mysetting=myvalue ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ console.log(result);
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ cmd = ('node cli.js site config list ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ var settingsList = JSON.parse(result.text);
+
+ // Listing should return 2 setting now
+ settingsList.length.should.equal(2);
+
+ // Delete created site
+ cmd = ('node cli.js site delete ' + siteName + ' --json --quiet').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ done();
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+});
View
@@ -1,5 +1 @@
-cli/commands/generate-psm1-utils-test.js
-cli/commands/cli.deployment-tests.js
-cli/commands/cli.site-tests.js
-cli/commands/cli.siteconfig-tests.js
-cli/linkrevisioncontrol-tests.js
+cli/commands/cli.siteconfig-tests.js

0 comments on commit ea1efbc

Please sign in to comment.