2015-02-10 19:41:24 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
"use server";
|
|
|
|
|
|
|
|
var assert = require("assert");
|
|
|
|
var git = require("./git");
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
"test validate urls" : function() {
|
|
|
|
assert.equal(git.isValidUrl("git@github.com:fjakobs/lispjs.git"), true);
|
|
|
|
assert.equal(git.isValidUrl("https://fjakobs@github.com/fjakobs/lispjs.git"), true);
|
|
|
|
assert.equal(git.isValidUrl("fjakobs@github.com/fjakobs/lispjs.git"), false);
|
|
|
|
assert.equal(git.isValidUrl("ftp://fjakobs@github.com/fjakobs/lispjs.git"), false);
|
|
|
|
assert.equal(git.isValidUrl("git://github.com/fjakobs/lispjs.git"), true);
|
|
|
|
assert.equal(git.isValidUrl("github.com:fjakobs/lispjs.git"), false);
|
|
|
|
assert.equal(git.isValidUrl("134"), false);
|
|
|
|
assert.equal(git.isValidUrl("god"), false);
|
|
|
|
},
|
|
|
|
|
|
|
|
"test parse ssh url" : function() {
|
|
|
|
var url = git.parse("git@github.com:fjakobs/lispjs.git");
|
|
|
|
assert.equal(url.protocol, "ssh:");
|
|
|
|
assert.equal(url.auth, "git");
|
|
|
|
assert.equal(url.hostname, "github.com");
|
|
|
|
assert.equal(url.pathname, "fjakobs/lispjs.git");
|
|
|
|
},
|
|
|
|
|
|
|
|
"test parse git url" : function() {
|
|
|
|
var url = git.parse("git://github.com/fjakobs/lispjs.git");
|
|
|
|
assert.equal(url.protocol, "git:");
|
|
|
|
assert.equal(url.hostname, "github.com");
|
|
|
|
assert.equal(url.pathname, "fjakobs/lispjs.git");
|
|
|
|
},
|
|
|
|
|
|
|
|
"test parse https url" : function() {
|
|
|
|
var url = git.parse("https://fjakobs@github.com/fjakobs/lispjs.git");
|
|
|
|
assert.equal(url.protocol, "https:");
|
|
|
|
assert.equal(url.auth, "fjakobs");
|
|
|
|
assert.equal(url.hostname, "github.com");
|
|
|
|
assert.equal(url.pathname, "fjakobs/lispjs.git");
|
|
|
|
},
|
|
|
|
|
|
|
|
"test parse Bitbucket url" : function() {
|
|
|
|
var url = git.parse("git@bitbucket.org/Richard/expressling.git");
|
|
|
|
assert.equal(url.protocol, "ssh:");
|
|
|
|
assert.equal(url.auth, "git");
|
|
|
|
assert.equal(url.hostname, "bitbucket.org");
|
|
|
|
assert.equal(url.pathname, "Richard/expressling.git");
|
|
|
|
},
|
|
|
|
|
|
|
|
"test get head revision": function(next) {
|
|
|
|
git.getHeadRevision(__dirname, function(err, rev) {
|
|
|
|
assert.equal(err, null);
|
|
|
|
assert.equal(rev.length, 40);
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
"test get head revision sync": function(next) {
|
2015-02-18 09:34:26 +00:00
|
|
|
var rev = git.getHeadRevisionSync(__dirname + "/../../");
|
2015-02-10 19:41:24 +00:00
|
|
|
assert.equal(rev.length, 40);
|
|
|
|
|
|
|
|
next();
|
2015-03-05 08:54:49 +00:00
|
|
|
},
|
2015-02-10 19:41:24 +00:00
|
|
|
|
|
|
|
"test get head branch": function(next) {
|
|
|
|
git.getHeadBranch(__dirname, function(err, rev) {
|
|
|
|
assert.equal(err, null);
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
}
|
2015-02-18 09:34:26 +00:00
|
|
|
};
|
2015-02-10 19:41:24 +00:00
|
|
|
|
|
|
|
!module.parent && require("asyncjs").test.testcase(module.exports).exec();
|