Skip to content

Commit

Permalink
Move tests to test/src folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tormozz48 committed Mar 12, 2015
1 parent f4f51b2 commit 9263533
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 33 deletions.
21 changes: 10 additions & 11 deletions src/targets/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var util = require('util'),
vow = require('vow'),

storage = require('../storage'),
logger = require('../logger'),
config = require('../config'),
utility = require('../util'),
mailer = require('../mailer'),
Expand Down Expand Up @@ -40,8 +39,8 @@ TargetRemove.prototype = {
*/
execute: function () {
if (this.options.isDryRun) {
logger.info('Remove command was launched in dry run mode', module);
logger.warn(util.format(
console.info('Remove command was launched in dry run mode', module);
console.warn(util.format(
'Data for %s %s won\' be removed from storage', this.source, this.ref), module);
}

Expand All @@ -63,19 +62,19 @@ TargetRemove.prototype = {
var portionSize = this.options.maxOpenFiles || config.get('maxOpenFiles') || constants.MAXIMUM_OPEN_FILES,
examplesRegistryKey = util.format('%s/%s/%s', this.source, this.ref, 'examples');

logger.info('Start to remove example records', module);
console.info('Start to remove example records', module);
return storage.get(this.options.storage).readP(examplesRegistryKey)
.then(function (content) {
var _this = this,
keys = JSON.parse(content),
portions = utility.separateArrayOnChunks(keys, portionSize);

logger.debug(util.format('example records count: %s', keys.length), module);
logger.debug(util.format('removing will be executed in %s steps', portions.length), module);
console.debug(util.format('example records count: %s', keys.length), module);
console.debug(util.format('removing will be executed in %s steps', portions.length), module);

return portions.reduce(function (prev, item, index) {
prev = prev.then(function () {
logger.debug(util.format('remove files in range %s - %s',
console.debug(util.format('remove files in range %s - %s',
index * portionSize, (index + 1) * portionSize), module);
return vow.all(item.map(function (_item) {
return _this.options.isDryRun ? vow.resolve() :
Expand All @@ -101,25 +100,25 @@ TargetRemove.prototype = {
noVersion: 'Library %s version %s was not found in registry. Operation will be skipped'
};

logger.info('Start to remove library from common registry', module);
console.info('Start to remove library from common registry', module);

// check if registry exists
if (!registry) {
logger.warn(message.noRegistry, module);
console.warn(message.noRegistry, module);
return vow.resolve();
}

registry = JSON.parse(registry);

// check if given library exists in registry
if (!registry[this.source]) {
logger.warn(util.format(message.noLibrary, this.source), module);
console.warn(util.format(message.noLibrary, this.source), module);
return vow.resolve();
}

// check if given library version exists in registry
if (!registry[this.source].versions[this.ref]) {
logger.warn(util.format(message.noVersion, this.source, this.ref), module);
console.warn(util.format(message.noVersion, this.source, this.ref), module);
return vow.resolve();
}

Expand Down
7 changes: 3 additions & 4 deletions src/targets/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var util = require('util'),

api = require('../gh-api'),
config = require('../config'),
logger = require('../logger'),
titles = require('../titles'),
utility = require('../util'),
constants = require('../constants'),
Expand Down Expand Up @@ -41,7 +40,7 @@ TargetReplace.prototype = {
* @returns {*}
*/
execute: function () {
logger.info('Replace documentation file', module);
console.info('Replace documentation file', module);
api.init();

var dataKey = util.format('%s/%s/%s', this.source, this.ref, constants.FILE.DATA);
Expand All @@ -59,7 +58,7 @@ TargetReplace.prototype = {
}

if (!content.docs) {
logger.warn('Docs section does not exists. It will be created', module);
console.warn('Docs section does not exists. It will be created', module);
content.docs = {};
}

Expand Down Expand Up @@ -108,7 +107,7 @@ TargetReplace.prototype = {
* @private
*/
_createDoc: function (content) {
logger.warn(util.format('Doc with key %s does not exists. It will be created', this.options.doc), module);
console.warn(util.format('Doc with key %s does not exists. It will be created', this.options.doc), module);
var languages = config.get('languages'),
_this = this,
_title = languages.reduce(function (prev, item) {
Expand Down
12 changes: 6 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('./targets/base');
require('./targets/publish');
require('./targets/prepare');
require('./targets/send');
require('./targets/view/api');
require('./targets/view/cli');
require('./src/targets/base');
require('./src/targets/publish');
require('./src/targets/prepare');
require('./src/targets/send');
require('./src/targets/view/api');
require('./src/targets/view/cli');
2 changes: 1 addition & 1 deletion test/targets/base.js → test/src/targets/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var should = require('should'),
Target = require('../../src/targets/base');
Target = require('../../../src/targets/base');

describe('targets base', function () {
it('should be initialized', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/targets/prepare.js → test/src/targets/prepare.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var should = require('should'),
Target = require('../../src/targets/prepare');
Target = require('../../../src/targets/prepare');

describe('targets prepare', function () {
it('should be initialized', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/targets/publish.js → test/src/targets/publish.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var should = require('should'),
Target = require('../../src/targets/publish');
Target = require('../../../src/targets/publish');

describe('targets publish', function () {
it('should be initialized', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/targets/send.js → test/src/targets/send.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var should = require('should'),
Target = require('../../src/targets/send');
Target = require('../../../src/targets/send');

describe('targets send', function () {
it('should be initialized', function () {
Expand Down
8 changes: 4 additions & 4 deletions test/targets/view/api.js → test/src/targets/view/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ var path = require('path'),
fs = require('fs'),
should = require('should'),
emulator = require('mds-wrapper/mds-emulator.js'),
Target = require('../../../src/targets/view/api.js'),
constants = require('../../../src/constants'),
storage = require('../../../src/storage');
Target = require('../../../../src/targets/view/api'),
constants = require('../../../../src/constants'),
storage = require('../../../../src/storage');

describe('targets view api', function () {
it('should be initialized', function () {
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('targets view api', function () {
describe('on filled registry', function () {
before(function () {
emulator.start(options.storage.get.port, options.storage.post.port);
var p = path.resolve(__dirname, '../../test-registry', 'data.json');
var p = path.resolve(__dirname, '../../../test-registry', 'data.json');
storage.get(options.storage).write(constants.ROOT, fs.readFileSync(p), null);
});

Expand Down
8 changes: 4 additions & 4 deletions test/targets/view/cli.js → test/src/targets/view/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ var path = require('path'),
fs = require('fs'),
should = require('should'),
emulator = require('mds-wrapper/mds-emulator.js'),
Target = require('../../../src/targets/view/cli.js'),
constants = require('../../../src/constants'),
storage = require('../../../src/storage');
Target = require('../../../../src/targets/view/cli.js'),
constants = require('../../../../src/constants'),
storage = require('../../../../src/storage');

describe('targets view cli', function () {
it('should be initialized', function () {
Expand All @@ -24,7 +24,7 @@ describe('targets view cli', function () {
describe('on filled registry', function () {
before(function () {
emulator.start(options.storage.get.port, options.storage.post.port);
var p = path.resolve(__dirname, '../../test-registry', 'data.json');
var p = path.resolve(__dirname, '../../../test-registry', 'data.json');
storage.get(options.storage).write(constants.ROOT, fs.readFileSync(p), null);
});

Expand Down

0 comments on commit 9263533

Please sign in to comment.