feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
1
api.hyungi.net/node_modules/vizion/test/fixtures/test_hg/contributors.txt
generated
vendored
Normal file
1
api.hyungi.net/node_modules/vizion/test/fixtures/test_hg/contributors.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
jshkurti
|
||||
22
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/branches/development/LICENSE
generated
vendored
Normal file
22
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/branches/development/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Joni Shkurti
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
4
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/branches/development/README.md
generated
vendored
Normal file
4
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/branches/development/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
vizionar_test
|
||||
=============
|
||||
|
||||
Empty repo for testing purposes !
|
||||
22
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/trunk/LICENSE
generated
vendored
Normal file
22
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/trunk/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Joni Shkurti
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
4
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/trunk/README.md
generated
vendored
Normal file
4
api.hyungi.net/node_modules/vizion/test/fixtures/test_svn/trunk/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
vizionar_test
|
||||
=============
|
||||
|
||||
Empty repo for testing purposes
|
||||
23
api.hyungi.net/node_modules/vizion/test/functional/cliCommand.test.js
generated
vendored
Normal file
23
api.hyungi.net/node_modules/vizion/test/functional/cliCommand.test.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
var expect = require('chai').expect;
|
||||
var cliCommand = require("../../lib/cliCommand.js");
|
||||
|
||||
describe('Functional: cliCommand', function () {
|
||||
|
||||
it("ok", function () {
|
||||
var target, folder;
|
||||
|
||||
if (/^win/.exec(process.platform)) {
|
||||
folder = "C:\\Program Files\\nodejs\\foobar";
|
||||
target = "cd \"" + folder + "\" && git status -s";
|
||||
}
|
||||
else {
|
||||
folder = "/etc/node/foobar";
|
||||
target = "cd '" + folder + "';LC_ALL=en_US.UTF-8 git status -s";
|
||||
}
|
||||
|
||||
|
||||
var result = cliCommand(folder, "git status -s");
|
||||
expect(target).to.eq(result);
|
||||
});
|
||||
|
||||
});
|
||||
207
api.hyungi.net/node_modules/vizion/test/functional/git.test.js
generated
vendored
Normal file
207
api.hyungi.net/node_modules/vizion/test/functional/git.test.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
var expect = require('chai').expect;
|
||||
var shell = require('shelljs');
|
||||
var vizion = require("../../index.js");
|
||||
var p = require('path');
|
||||
|
||||
if (shell.which('git') === null) process.exit(0);
|
||||
|
||||
describe('Functional: Git', function () {
|
||||
var testRepoPath = '';
|
||||
var tmp_meta = {};
|
||||
|
||||
before(function (done) {
|
||||
shell.cd('test/fixtures');
|
||||
|
||||
shell.rm('-rf', 'angular-bridge');
|
||||
shell.exec('git clone https://github.com/Unitech/angular-bridge.git', () => {
|
||||
testRepoPath = p.join(shell.pwd().toString(), 'angular-bridge');
|
||||
done()
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
shell.rm('-rf', 'angular-bridge');
|
||||
shell.cd('../..'); // go back to root
|
||||
});
|
||||
|
||||
it('should recursively downgrade to first commit', function (done) {
|
||||
var callback = function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (meta.success === true) {
|
||||
vizion.prev({folder: testRepoPath}, callback);
|
||||
}
|
||||
else {
|
||||
expect(meta.success).to.eq(false);
|
||||
vizion.analyze({folder: testRepoPath}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.prev_rev).to.eq(null);
|
||||
expect(meta.revision).to.eq('445c0b78e447e87eaec2140d32f67652108b434e');
|
||||
done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
vizion.prev({folder: testRepoPath}, callback);
|
||||
});
|
||||
|
||||
it('should recursively upgrade to most recent commit', function (done) {
|
||||
var callback = function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (meta.success === true) {
|
||||
vizion.next({folder: testRepoPath}, callback);
|
||||
}
|
||||
else {
|
||||
expect(meta.success).to.eq(false);
|
||||
vizion.analyze({folder: testRepoPath}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
expect(meta.next_rev).to.eq(null);
|
||||
expect(meta.revision).to.eq('d1dee188a0d82f21c05a398704ac3237f5523ca7');
|
||||
done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
vizion.next({folder: testRepoPath}, callback);
|
||||
});
|
||||
|
||||
describe('at head', function () {
|
||||
|
||||
describe('analyze', function () {
|
||||
it('ok', function (done) {
|
||||
console.log('start')
|
||||
vizion.analyze({folder: testRepoPath}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.type).to.eq('git');
|
||||
expect(meta.url).to.eq('https://github.com/Unitech/angular-bridge.git');
|
||||
expect(meta.branch).to.eq('master');
|
||||
expect(meta.comment).to.eq('Merge pull request #17 from jorge-d/express_4\n\nExpress 4');
|
||||
expect(meta.unstaged).to.eq(false);
|
||||
expect(meta.branch).to.eq('master');
|
||||
expect(meta.remotes).to.deep.eq(['origin']);
|
||||
expect(meta.remote).to.eq('origin');
|
||||
expect(meta.branch_exists_on_remote).to.eq(true);
|
||||
expect(meta.ahead).to.eq(false);
|
||||
expect(meta.next_rev).to.eq(null);
|
||||
expect(meta.prev_rev).to.eq('da29de44b4884c595468b6978fb19f17bee76893');
|
||||
expect(meta.tags).to.deep.eq(['v0.3.4']);
|
||||
|
||||
tmp_meta = meta;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isUpToDate', function () {
|
||||
it('up to date', function (done) {
|
||||
vizion.isUpToDate({
|
||||
folder: testRepoPath
|
||||
}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.is_up_to_date).to.eq(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('previous commit', function () {
|
||||
before(function beforeTest(done) {
|
||||
vizion.revertTo({
|
||||
folder: testRepoPath,
|
||||
revision: 'eb488c1ca9024b6da2d65ef34dc1544244d8c714'
|
||||
}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.success).to.eq(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('analyze', function () {
|
||||
|
||||
it('ok', function it(done) {
|
||||
vizion.analyze({folder: testRepoPath}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.type).to.eq('git');
|
||||
expect(meta.branch).to.eq('master');
|
||||
expect(meta.comment).to.eq('Fix indentation\n');
|
||||
expect(meta.unstaged).to.eq(false);
|
||||
expect(meta.branch).to.eq('master');
|
||||
expect(meta.remotes).to.deep.eq(['origin']);
|
||||
expect(meta.remote).to.eq('origin');
|
||||
expect(meta.branch_exists_on_remote).to.eq(true);
|
||||
expect(meta.ahead).to.eq(false);
|
||||
expect(meta.next_rev).to.eq('759120ab5b19953886424b7c847879cf7f4cb28e');
|
||||
expect(meta.prev_rev).to.eq('0c0cb178a3de0b8c69a81d1fd2f0d72fe0f23a11');
|
||||
expect(meta.tags).to.deep.eq(['v0.3.4']);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isUpToDate', function () {
|
||||
it('not up to date', function (done) {
|
||||
vizion.isUpToDate({
|
||||
folder: testRepoPath
|
||||
}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.is_up_to_date).to.eq(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', function () {
|
||||
it('should update to latest', function (done) {
|
||||
vizion.update({
|
||||
folder: testRepoPath
|
||||
}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.success).to.eq(true);
|
||||
|
||||
vizion.analyze({folder: testRepoPath}, function (err, meta) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(meta.revision).to.eq('d1dee188a0d82f21c05a398704ac3237f5523ca7');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
61
api.hyungi.net/node_modules/vizion/test/functional/svn-hg.test.js
generated
vendored
Normal file
61
api.hyungi.net/node_modules/vizion/test/functional/svn-hg.test.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
var assert = require("assert");
|
||||
var shell = require("shelljs");
|
||||
var vizion = require("../../index.js");
|
||||
|
||||
/*
|
||||
To enable a sample test suite, remove the _disabled
|
||||
and fill in the strings. One way to fetch these values is to
|
||||
create the sample directory, enter it as the directory,
|
||||
and then run this test suite (npm test).
|
||||
The test will return the expected value (a blank string),
|
||||
and the actual value, which can be then used as the string to
|
||||
test.
|
||||
*/
|
||||
var sample = {
|
||||
svn: {
|
||||
directory: "./test/fixtures/test_svn/",
|
||||
url: "https://github.com/jshkurti/vizionar_test",
|
||||
revision: "r3",
|
||||
comment: "dat commit though",
|
||||
branch: "vizionar_test",
|
||||
update_time: "2014-10-21T12:29:21.289Z"
|
||||
},
|
||||
hg: {
|
||||
directory: "./test/fixtures/test_hg/",
|
||||
url: "https://jshkurti@bitbucket.org/jshkurti/vizionar_test",
|
||||
revision: "0:a070c08854c3",
|
||||
comment: "Initial commit with contributors",
|
||||
branch: "default",
|
||||
update_time: "2014-10-21T12:42:31.017Z"
|
||||
}
|
||||
};
|
||||
|
||||
describe("vizion.analyze()", function() {
|
||||
if (shell.which('svn')) {
|
||||
it.skip("Pulling from Subversion", function(done) {
|
||||
this.timeout(5000);
|
||||
vizion.analyze({folder: sample.svn.directory}, function(err, metadata) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(metadata.url, sample.svn.url);
|
||||
assert.equal(metadata.revision, sample.svn.revision);
|
||||
assert.equal(metadata.comment, sample.svn.comment);
|
||||
assert.equal(metadata.branch, sample.svn.branch);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
if (shell.which('hg')) {
|
||||
it("Pulling from Mercurial", function(done) {
|
||||
this.timeout(5000);
|
||||
vizion.analyze({folder: sample.hg.directory}, function(err, metadata) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(metadata.url, sample.hg.url);
|
||||
assert.equal(metadata.revision, sample.hg.revision);
|
||||
assert.equal(metadata.comment, sample.hg.comment);
|
||||
assert.equal(metadata.branch, sample.hg.branch);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
6
api.hyungi.net/node_modules/vizion/test/mocha.opts
generated
vendored
Normal file
6
api.hyungi.net/node_modules/vizion/test/mocha.opts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
--timeout 20000
|
||||
--reporter spec
|
||||
--bail
|
||||
--check-leaks
|
||||
--require test/support/env
|
||||
test/**/*.test.js
|
||||
2
api.hyungi.net/node_modules/vizion/test/support/env.js
generated
vendored
Normal file
2
api.hyungi.net/node_modules/vizion/test/support/env.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
326
api.hyungi.net/node_modules/vizion/test/unit/git.test.js
generated
vendored
Normal file
326
api.hyungi.net/node_modules/vizion/test/unit/git.test.js
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
var expect = require('chai').expect;
|
||||
var fs = require('fs');
|
||||
var sinon = require('sinon');
|
||||
var ini = require('ini');
|
||||
|
||||
var git = require("../../lib/git/git.js");
|
||||
var jsGitService = require("../../lib/git/js-git-service.js");
|
||||
|
||||
|
||||
describe('Unit: git', function () {
|
||||
|
||||
describe('parseGitConfig', function parseGitConfigTest() {
|
||||
var folder = "my-folder";
|
||||
var config = {stub: 'config'};
|
||||
var data = {stub: 'data'};
|
||||
var readFileStub, parseStub;
|
||||
|
||||
before(function beforeTest() {
|
||||
readFileStub = sinon.stub(fs, 'readFile').callsFake(function (path, encoding, cb) {
|
||||
if (process.platform !== 'win32' && process.platform !== 'win64')
|
||||
expect(path).to.eq('my-folder/.git/config');
|
||||
else
|
||||
expect(path).to.eq('my-folder\\.git\\config');
|
||||
|
||||
cb(null, data);
|
||||
});
|
||||
|
||||
parseStub = sinon.stub(ini, 'parse').callsFake(function (myData) {
|
||||
expect(myData).to.eq(data);
|
||||
|
||||
return config;
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.parseGitConfig(folder, function (err, myConfig) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(myConfig).to.eq(config);
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
readFileStub.restore();
|
||||
parseStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUrl', function getUrlTest() {
|
||||
var folder = "my-folder";
|
||||
var config = {
|
||||
'remote "origin"': {
|
||||
url: 'test-url'
|
||||
}
|
||||
};
|
||||
var parseGitConfigStub;
|
||||
|
||||
before(function beforeTest() {
|
||||
parseGitConfigStub = sinon.stub(git, 'parseGitConfig').callsFake(function (myFolder, cb) {
|
||||
expect(myFolder).to.eq(folder);
|
||||
|
||||
cb(null, config);
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.getUrl(folder, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"type": "git",
|
||||
"url": "test-url"
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
parseGitConfigStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getCommitInfo', function getCommitInfoTest() {
|
||||
var folder = "my-folder";
|
||||
var commit = {
|
||||
hash: 'xfd4560',
|
||||
message: 'my message'
|
||||
};
|
||||
var data = {};
|
||||
var getHeadCommitStub;
|
||||
|
||||
before(function beforeTest() {
|
||||
getHeadCommitStub = sinon.stub(jsGitService, 'getHeadCommit').callsFake(function (myFolder, cb) {
|
||||
expect(myFolder).to.eq(folder);
|
||||
|
||||
cb(null, commit);
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.getCommitInfo(folder, data, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"revision": commit.hash,
|
||||
"comment": commit.message
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
getHeadCommitStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getBranch', function getBranchTest() {
|
||||
var folder = "my-folder";
|
||||
var data = {};
|
||||
var readFileStub;
|
||||
|
||||
before(function beforeTest() {
|
||||
readFileStub = sinon.stub(fs, 'readFile').callsFake(function (path, encoding, cb) {
|
||||
if (process.platform !== 'win32' && process.platform !== 'win64')
|
||||
expect(path).to.eq('my-folder/.git/HEAD');
|
||||
else
|
||||
expect(path).to.eq('my-folder\\.git\\HEAD');
|
||||
expect(encoding).to.eq('utf-8');
|
||||
|
||||
cb(null, "ref: refs/heads/master");
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.getBranch(folder, data, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"branch": "master",
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
readFileStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRemote', function getRemoteTest() {
|
||||
var folder = "my-folder";
|
||||
var config = {
|
||||
'remote "origin"': {
|
||||
url: 'test-url'
|
||||
},
|
||||
'remote "other"': {
|
||||
url: 'other-url'
|
||||
}
|
||||
};
|
||||
var data = {};
|
||||
var parseGitConfigStub;
|
||||
|
||||
before(function beforeTest() {
|
||||
parseGitConfigStub = sinon.stub(git, 'parseGitConfig').callsFake(function (myFolder, cb) {
|
||||
expect(myFolder).to.eq(folder);
|
||||
|
||||
cb(null, config);
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.getRemote(folder, data, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"remote": "origin",
|
||||
"remotes": [
|
||||
"origin",
|
||||
"other"
|
||||
]
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
parseGitConfigStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('isCurrentBranchOnRemote', function isCurrentBranchOnRemoteTest() {
|
||||
var folder = "my-folder";
|
||||
var data = {
|
||||
branch: 'my-branch',
|
||||
remote: 'my-remote'
|
||||
};
|
||||
var getRefHashStub;
|
||||
|
||||
context('not on remote', function () {
|
||||
before(function beforeTest() {
|
||||
getRefHashStub = sinon.stub(jsGitService, 'getRefHash').callsFake(function (myFolder,myBranch,myRemote, cb) {
|
||||
expect(myFolder).to.eq(folder);
|
||||
expect(myBranch).to.eq(data.branch);
|
||||
expect(myRemote).to.eq(data.remote);
|
||||
|
||||
cb(null, null);
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.isCurrentBranchOnRemote(folder, data, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"branch": "my-branch",
|
||||
"branch_exists_on_remote": false,
|
||||
"remote": "my-remote"
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
getRefHashStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
context('on remote', function () {
|
||||
before(function beforeTest() {
|
||||
getRefHashStub = sinon.stub(jsGitService, 'getRefHash').callsFake(function (myFolder,myBranch,myRemote, cb) {
|
||||
expect(myFolder).to.eq(folder);
|
||||
expect(myBranch).to.eq(data.branch);
|
||||
expect(myRemote).to.eq(data.remote);
|
||||
|
||||
cb(null, "FX421345CX");
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.isCurrentBranchOnRemote(folder, data, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"branch": "my-branch",
|
||||
"branch_exists_on_remote": true,
|
||||
"remote": "my-remote"
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
getRefHashStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getPrevNext', function getPrevNextTest() {
|
||||
var folder = "my-folder";
|
||||
var data = {
|
||||
branch_exists_on_remote:true,
|
||||
branch: 'my-branch',
|
||||
remote: 'my-remote',
|
||||
revision: '2'
|
||||
};
|
||||
var commitHistory = [
|
||||
{hash: '3'},
|
||||
{hash: '2'},
|
||||
{hash: '1'},
|
||||
];
|
||||
var getCommitHistoryStub;
|
||||
|
||||
before(function beforeTest() {
|
||||
getCommitHistoryStub = sinon.stub(jsGitService, 'getCommitHistory').callsFake(function (myFolder, n, myBranch, myRemote, cb) {
|
||||
expect(myFolder).to.eq(folder);
|
||||
expect(n).to.eq(100);
|
||||
expect(myBranch).to.eq(data.branch);
|
||||
expect(myRemote).to.eq(data.remote);
|
||||
|
||||
cb(null, commitHistory);
|
||||
});
|
||||
});
|
||||
|
||||
it('ok', function it(done) {
|
||||
git.getPrevNext(folder, data, function (err, data) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
expect(data).to.deep.eq({
|
||||
"ahead": false,
|
||||
"branch": "my-branch",
|
||||
"branch_exists_on_remote": true,
|
||||
"next_rev": "3",
|
||||
"prev_rev": "1",
|
||||
"remote": "my-remote",
|
||||
"revision": "2"
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function afterTest() {
|
||||
getCommitHistoryStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
26
api.hyungi.net/node_modules/vizion/test/unit/helper.test.js
generated
vendored
Normal file
26
api.hyungi.net/node_modules/vizion/test/unit/helper.test.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
var helper = require("../../lib/helper.js");
|
||||
var should = require("should");
|
||||
|
||||
describe('Helper', function () {
|
||||
|
||||
const fixt = {
|
||||
a : {
|
||||
b : {
|
||||
c : 'result'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('.get', () => {
|
||||
should(helper.get(fixt, 'a.b.c')).eql('result')
|
||||
})
|
||||
|
||||
describe('.get null', () => {
|
||||
should(helper.get(null, 'a.b.c')).eql(null)
|
||||
})
|
||||
|
||||
describe('.get null', () => {
|
||||
should(helper.get(fixt, 'a.b.d')).eql(undefined)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user