git2consul
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -10,2 +10,3 @@ var fs = require('fs'); | ||
/* istanbul ignore next */ | ||
exports.setToken = function(tok) { | ||
@@ -35,5 +36,4 @@ token = tok; | ||
fs.readFile(fqf, {encoding:'utf8'}, function(err, body) { | ||
// TODO: Test a non-UTF8 file | ||
/* istanbul ignore if */ | ||
if (err) return cb('Failed to read key ' + fqf + ' due to ' + err); | ||
// TODO: Test an empty file | ||
var body = body ? body.trim() : ''; | ||
@@ -40,0 +40,0 @@ write_content_to_consul(branch_manager, branch_manager.getBranchName() + '/' + file, body, cb); |
{ | ||
"name": "git2consul", | ||
"description": "System for moving data from git to consul", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -23,3 +23,3 @@ var should = require('should'); | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -26,0 +26,0 @@ return function(done) { |
@@ -67,3 +67,3 @@ var _ = require('underscore'); | ||
it ('should reject a repo with a broken git url', function(done) { | ||
git_manager.manageRepo(_.extend(git_utils.createConfig().repos[0], { local_store:'/tmp/busted', url: 'file:///tmp/nobody_home' }), function(err) { | ||
git_manager.manageRepo(_.extend(git_utils.createRepoConfig(), { local_store:'/tmp/busted', url: 'file:///tmp/nobody_home' }), function(err) { | ||
err.should.startWith('Failed to create manager for branch master'); | ||
@@ -75,3 +75,3 @@ done(); | ||
it ('should reject an invalid git hook type', function(done) { | ||
git_manager.manageRepo(_.extend(git_utils.createConfig().repos[0], { hooks: [ { 'type': 'unknown' }] }), function(err, gm) { | ||
git_manager.manageRepo(_.extend(git_utils.createRepoConfig(), { hooks: [ { 'type': 'unknown' }] }), function(err, gm) { | ||
err[0].should.startWith('Invalid hook type'); | ||
@@ -81,2 +81,9 @@ done(); | ||
}); | ||
it ('should handle config validation if multiple repos initialized at the same time', function(done) { | ||
git_manager.manageRepos([_.extend(git_utils.createRepoConfig(), { hooks: [ { 'type': 'unknown' }] })], function(err, gm) { | ||
err[0][0].should.startWith('Invalid hook type'); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -19,3 +19,3 @@ var should = require('should'); | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -25,3 +25,3 @@ it ('should handle updates to a single file', function(done) { | ||
var sample_value = 'new test data'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Update a file.", function(err) { | ||
@@ -40,3 +40,3 @@ if (err) return done(err); | ||
var sample_value = 'new value'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Add a file.", function(err) { | ||
@@ -55,3 +55,3 @@ if (err) return done(err); | ||
var sample_value = 'new value'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file to delete.", function(err) { | ||
@@ -78,3 +78,3 @@ if (err) return done(err); | ||
var sample_value = 'movable value'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file to move.", function(err) { | ||
@@ -105,3 +105,3 @@ if (err) return done(err); | ||
var sample_value = 'movable value'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file to move to subfolder.", function(err) { | ||
@@ -135,3 +135,3 @@ if (err) return done(err); | ||
var sample_value = 'linked value'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file for symlinking.", function(err) { | ||
@@ -138,0 +138,0 @@ if (err) return done(err); |
@@ -1,2 +0,1 @@ | ||
var crypto = require('crypto'); | ||
var should = require('should'); | ||
@@ -16,3 +15,3 @@ var _ = require('underscore'); | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -58,3 +57,3 @@ var buffer_test = function(size, cb) { | ||
var sample_value = ''; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Add a file.", function(err) { | ||
@@ -61,0 +60,0 @@ if (err) return done(err); |
@@ -19,3 +19,3 @@ var should = require('should'); | ||
var sample_value = 'test data'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Clone test.", false, function(err) { | ||
@@ -26,3 +26,3 @@ if (err) return done(err); | ||
var sample_value2 = 'test data2'; | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
git_utils.addFileToGitRepo(sample_key2, sample_value2, "Second file for clone test.", function(err) { | ||
@@ -47,6 +47,5 @@ if (err) return done(err); | ||
it ('should handle creating a git_manager tracking multiple branches', function(done) { | ||
var config = git_utils.createConfig(); | ||
var branches = ['dev', 'test', 'prod']; | ||
config.repos[0].branches = branches; | ||
var repo_config = git_utils.createRepoConfig(); | ||
repo_config.branches = branches; | ||
var branch_tests = []; | ||
@@ -64,3 +63,3 @@ var create_branch_and_add = function(branch_name, done) { | ||
if (branch_tests.length === 0) { | ||
git_manager.manageRepo(config.repos[0], function(err, gm) { | ||
git_manager.manageRepo(repo_config, function(err, gm) { | ||
if (err) return done(err); | ||
@@ -96,3 +95,3 @@ done(); | ||
it ('should handle creating a git_manager around a repo that already exists', function(done) { | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -116,3 +115,3 @@ var sample_key = 'sample_key'; | ||
it ('should handle creating a git_manager around a repo that is been emptied', function(done) { | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -134,3 +133,3 @@ // This addFileToGitRepo will automatically create a git_manager in git_utils, so once the callback | ||
it ('should handle populating consul when you create a git_manager around a repo that is already on disk', function(done) { | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -177,6 +176,9 @@ var sample_key = 'sample_key'; | ||
var sample_value = 'test data'; | ||
var default_repo_config = git_utils.createConfig(); | ||
var default_config = { | ||
version: '1.0', | ||
repos: [git_utils.createRepoConfig()] | ||
}; | ||
// Add a Github repo to our repo config because we want to initialize multiple repos at once. | ||
default_repo_config.repos.push({ | ||
default_config.repos.push({ | ||
name: 'test_github_repo', | ||
@@ -194,3 +196,3 @@ local_store: git_utils.TEST_GITHUB_WORKING_DIR, | ||
git_manager.manageRepos(default_repo_config.repos, function(err, gms) { | ||
git_manager.manageRepos(default_config.repos, function(err, gms) { | ||
if (err) return done(err); | ||
@@ -197,0 +199,0 @@ |
@@ -15,3 +15,3 @@ var should = require('should'); | ||
var default_repo_config = git_utils.createConfig().repos[0]; | ||
var default_repo_config = git_utils.createRepoConfig(); | ||
@@ -18,0 +18,0 @@ var test_add = function(key_name, key_value) { |
@@ -49,3 +49,3 @@ var should = require('should'); | ||
it ('should reject invalid webhook config', function(done) { | ||
var config = git_utils.createConfig().repos[0]; | ||
var config = git_utils.createRepoConfig(); | ||
config.hooks = hook_config; | ||
@@ -140,3 +140,3 @@ | ||
before(function(done) { | ||
var config = git_utils.createConfig().repos[0]; | ||
var config = git_utils.createRepoConfig(); | ||
config.hooks = hook_config; | ||
@@ -209,3 +209,3 @@ | ||
it ('should reject invalid polling config', function(done) { | ||
var config = git_utils.createConfig().repos[0]; | ||
var config = git_utils.createRepoConfig(); | ||
config.hooks = hook_config; | ||
@@ -229,3 +229,3 @@ | ||
before(function(done) { | ||
var config = git_utils.createConfig().repos[0]; | ||
var config = git_utils.createRepoConfig(); | ||
config.hooks = [{ | ||
@@ -232,0 +232,0 @@ 'type': 'polling', |
@@ -11,11 +11,8 @@ var fs = require('fs'); | ||
exports.createConfig = function() { | ||
exports.createRepoConfig = function() { | ||
return { | ||
version: '1.0', | ||
repos: [{ | ||
name: 'test_repo', | ||
local_store: exports.TEST_WORKING_DIR, | ||
url: 'file://' + exports.TEST_REMOTE_REPO, | ||
branches: [ 'master' ] | ||
}] | ||
name: 'test_repo', | ||
local_store: exports.TEST_WORKING_DIR, | ||
url: 'file://' + exports.TEST_REMOTE_REPO, | ||
branches: [ 'master' ] | ||
}; | ||
@@ -31,3 +28,3 @@ }; | ||
git_manager.manageRepo(exports.createConfig().repos[0], function(err, gm) { | ||
git_manager.manageRepo(exports.createRepoConfig(), function(err, gm) { | ||
if (err) return cb(err); | ||
@@ -34,0 +31,0 @@ |
81918
1788