forked from breser/git2consul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit2consul_mountpoint_test.js
71 lines (54 loc) · 2.51 KB
/
git2consul_mountpoint_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var should = require('should');
var _ = require('underscore');
var path = require('path');
// We want this above any git2consul module to make sure logging gets configured
require('./git2consul_bootstrap_test.js');
var rimraf = require('rimraf');
var consul_utils = require('./utils/consul_utils.js');
var git = require('../lib/git');
var Repo = require('../lib/git/repo.js');
var git_utils = require('./utils/git_utils.js');
var git_commands = require('../lib/git/commands.js');
describe('KV mountpoint', function() {
it ('should support setting a custom mountpoint for keys', function(done) {
// Create a remote git repo. Then, init a Repo object with include_branch_name disabled and validate
// that files are in the appropriate place in the Consul KV store.
git_commands.init(git_utils.TEST_REMOTE_REPO, function(err) {
if (err) return done(err);
git_utils.addFileToGitRepo("readme.md", "Test file mountpointed KV", "Test commit.", function(err) {
if (err) return done(err);
var repo_config = git_utils.createRepoConfig();
repo_config.mountpoint = "nested/enough/for/my/purposes";
var repo = new Repo(repo_config);
repo.init(function(err) {
if (err) return done(err);
consul_utils.validateValue('nested/enough/for/my/purposes/test_repo/master/readme.md', "Test file mountpointed KV", function(err, value) {
if (err) return done(err);
done();
});
});
});
});
});
it ('custom mountpoints should work with include_branch_name disabled', function(done) {
// Create a remote git repo. Then, init a Repo object with include_branch_name disabled and validate
// that files are in the appropriate place in the Consul KV store.
git_commands.init(git_utils.TEST_REMOTE_REPO, function(err) {
if (err) return done(err);
git_utils.addFileToGitRepo("readme.md", "Test file mountpointed KV", "Test commit.", function(err) {
if (err) return done(err);
var repo_config = git_utils.createRepoConfig();
repo_config.mountpoint = "nested/enough/for/my/purposes";
repo_config.include_branch_name = false;
var repo = new Repo(repo_config);
repo.init(function(err) {
if (err) return done(err);
consul_utils.validateValue('nested/enough/for/my/purposes/test_repo/readme.md', "Test file mountpointed KV", function(err, value) {
if (err) return done(err);
done();
});
});
});
});
});
});