Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding UT

  • Loading branch information...
commit cef24f9bb5d70588dd250ab357ec5f631cb1520d 1 parent 2ee47c2
@andrerod andrerod authored
View
18 lib/cli/linkedrevisioncontrol.js
@@ -115,7 +115,7 @@ GithubClient.prototype.init = function GithubClient_prototype_init__5(context, _
return __this.getRepositories(context.username, __cb(_, __frame, 4, 21, function ___(__0, __1) { repositories = __1;
- return __this._getRemoteUri(context, __cb(_, __frame, 6, 22, function ___(__0, __2) { context.remoteUri = __2;
+ return __this._getRemoteUri(__cb(_, __frame, 6, 22, function ___(__0, __2) { context.remoteUri = __2;
if (context.remoteUri) {
parsedRepositoryUri = url.parse(context.remoteUri);
pathParts = parsedRepositoryUri.pathname.split("/");
@@ -257,7 +257,7 @@ GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__11(u
-GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemoteUri__12(context, _) { var progress, originUri, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUri__12", line: 260 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUri__12, 1, __frame, function __$GithubClient_prototype__getRemoteUri__12() {
+GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemoteUri__12(_) { var progress, originUri, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUri__12", line: 260 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUri__12, 0, __frame, function __$GithubClient_prototype__getRemoteUri__12() {
progress = __this.cli.progress("Retrieving local git repositories");
originUri = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype__getRemoteUri__12() {
@@ -273,12 +273,8 @@ GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemot
return _(null, originUri); }); }); });};
-function choose(cli, data, callback) {
- cli.choose(data, function(x) { callback(undefined, x); });};
-
-
-GithubClient.prototype._getRemote = function GithubClient_prototype__getRemote__13(name, _) { var origin, __this = this; var __frame = { name: "GithubClient_prototype__getRemote__13", line: 280 }; return __func(_, this, arguments, GithubClient_prototype__getRemote__13, 1, __frame, function __$GithubClient_prototype__getRemote__13() {
- return __this._exec("git remote -v", __cb(_, __frame, 1, 12, function ___(__0, __1) { remotes = __1;
+GithubClient.prototype._getRemote = function GithubClient_prototype__getRemote__13(name, _) { var remotes, origin, __this = this; var __frame = { name: "GithubClient_prototype__getRemote__13", line: 276 }; return __func(_, this, arguments, GithubClient_prototype__getRemote__13, 1, __frame, function __$GithubClient_prototype__getRemote__13() {
+ return __this._exec("git remote -v", __cb(_, __frame, 1, 16, function ___(__0, __1) { remotes = __1;
origin = ((remotes.stdout + remotes.stderr)).split("\n").filter(function(item) {
return item.split(" ").some(function(it) {
return (it === name); }); });
@@ -289,4 +285,8 @@ GithubClient.prototype._getRemote = function GithubClient_prototype__getRemote__
return _(null, origin[0].split(" ")[1].split(" ")[0]); } ;
- return _(null, null); }, true)); });};
+ return _(null, null); }, true)); });};
+
+
+function choose(cli, data, callback) {
+ cli.choose(data, function(x) { callback(undefined, x); });};
View
16 lib/cli/linkedrevisioncontrol_.js
@@ -115,7 +115,7 @@ GithubClient.prototype.init = function (context, _) {
var repositories = this.getRepositories(context.username, _);
- context.remoteUri = this._getRemoteUri(context, _);
+ context.remoteUri = this._getRemoteUri(_);
if (context.remoteUri) {
var parsedRepositoryUri = url.parse(context.remoteUri);
var pathParts = parsedRepositoryUri.pathname.split('/');
@@ -257,7 +257,7 @@ GithubClient.prototype.getHooks = function (username, repository, _) {
}
};
-GithubClient.prototype._getRemoteUri = function (context, _) {
+GithubClient.prototype._getRemoteUri = function (_) {
var progress = this.cli.progress('Retrieving local git repositories');
var originUri = null;
@@ -273,12 +273,8 @@ GithubClient.prototype._getRemoteUri = function (context, _) {
return originUri;
};
-function choose(cli, data, callback) {
- cli.choose(data, function (x) { callback(undefined, x); });
-}
-
GithubClient.prototype._getRemote = function (name, _) {
- remotes = this._exec('git remote -v', _);
+ var remotes = this._exec('git remote -v', _);
var origin = (remotes.stdout + remotes.stderr).split('\n').filter(function (item) {
return item.split('\t').some(function (it) {
return it === name;
@@ -290,4 +286,8 @@ GithubClient.prototype._getRemote = function (name, _) {
}
return null;
-}
+};
+
+function choose(cli, data, callback) {
+ cli.choose(data, function (x) { callback(undefined, x); });
+}
View
78 test/cli/linkrevisioncontrol-tests.js
@@ -13,10 +13,11 @@
* limitations under the License.
*/
-require('should');
+var should = require('should');
var sinon = require('sinon');
-var cli = require('../cli');
-var capture = require('../util').capture;
+var cli = require('./cli');
+var capture = require('./util').capture;
+var LinkedRevisionControl = require('../../lib/cli/linkedrevisioncontrol');
var sandbox;
@@ -34,10 +35,73 @@ suite('cli', function(){
done();
});
- test('should list no sites', function(done) {
-
+ test('should get remote azure uri', function(done) {
+ // Setup
+ var azureUrl = {
+ stdout: 'azure\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
+ 'azure\tgit://github.com/andrerod/mynewsite999.git (push)\n',
+ stderr: ''
+ };
+
+ var cli = { output: { }, progress: function() { return { end: function() {}}} };
+ var githubClient = LinkedRevisionControl.createClient(cli, 'github');
+
+ var execStub = sandbox.stub(githubClient, '_exec');
+ execStub.yields(undefined, azureUrl);
+
+ // Test
+ githubClient._getRemoteUri(function (err, url) {
+ // Assert
+ url.should.equal('git://github.com/andrerod/mynewsite999.git');
+
+ done();
+ })
});
- });
-});
+ test('should get remote origin uri', function(done) {
+ // Setup
+ var originUrl = {
+ stdout: 'origin\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
+ 'origin\tgit://github.com/andrerod/mynewsite999.git (push)\n',
+ stderr: ''
+ };
+
+ var cli = { output: { }, progress: function() { return { end: function() {}}} };
+ var githubClient = LinkedRevisionControl.createClient(cli, 'github');
+
+ var execStub = sandbox.stub(githubClient, '_exec');
+ execStub.yields(undefined, originUrl);
+
+ // Test
+ githubClient._getRemoteUri(function (err, url) {
+ // Assert
+ url.should.equal('git://github.com/andrerod/mynewsite999.git');
+ done();
+ })
+ });
+
+ test('should not get other remote uris', function(done) {
+ // Setup
+ var originUrl = {
+ stdout: 'myremote\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
+ 'myremote\tgit://github.com/andrerod/mynewsite999.git (push)\n',
+ stderr: ''
+ };
+
+ var cli = { output: { }, progress: function() { return { end: function() {}}} };
+ var githubClient = LinkedRevisionControl.createClient(cli, 'github');
+
+ var execStub = sandbox.stub(githubClient, '_exec');
+ execStub.yields(undefined, originUrl);
+
+ // Test
+ githubClient._getRemoteUri(function (err, url) {
+ // Assert
+ should.strictEqual(undefined, url);
+
+ done();
+ })
+ });
+ });
+});
View
1  test/testlist.txt
@@ -1,3 +1,4 @@
+cli/linkrevisioncontrol-tests.js
cli/commands/generate-psm1-utils-test.js
serviceruntime/roleenvironment-tests.js
serviceruntime/runtimeversionmanager-tests.js
Please sign in to comment.
Something went wrong with that request. Please try again.