Skip to content

Commit 51c309c

Browse files
committed
Test with real git dir
New code fails with fake .git dir as it doesn't guess, it asks git.
1 parent e83af69 commit 51c309c

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

tests/install.test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
require('chai').should();
2+
var execSync = require('child_process').execSync;
23
var gitHooks = require('../lib/git-hooks');
34
var fsHelpers = require('../lib/fs-helpers');
45

5-
var SANDBOX_PATH = __dirname + '/tmp-sandbox/';
6+
var SANDBOX_PATH = '/tmp/tmp-sandbox/';
67
var GIT_ROOT = SANDBOX_PATH + '.git/';
78
var GIT_HOOKS = GIT_ROOT + 'hooks';
89
var GIT_HOOKS_OLD = GIT_ROOT + 'hooks.old';
910

1011
describe('--install', function () {
1112
beforeEach(function () {
12-
fsHelpers.makeDir(GIT_ROOT);
13+
fsHelpers.makeDir(SANDBOX_PATH);
14+
execSync('git init', {cwd: SANDBOX_PATH});
1315
});
1416

1517
afterEach(function () {
@@ -35,10 +37,6 @@ describe('--install', function () {
3537
});
3638

3739
describe('when some hooks already exist', function () {
38-
beforeEach(function () {
39-
fsHelpers.makeDir(GIT_HOOKS);
40-
});
41-
4240
it('should backup hooks before installation', function () {
4341
gitHooks.install(SANDBOX_PATH);
4442
fsHelpers.exists(GIT_HOOKS_OLD).should.be.true;

tests/run.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
require('chai').should();
2+
var execSync = require('child_process').execSync;
23
var fs = require('fs');
34
var gitHooks = require('../lib/git-hooks');
45
var fsHelpers = require('../lib/fs-helpers');
56

6-
var SANDBOX_PATH = __dirname + '/tmp-sandbox/';
7+
var SANDBOX_PATH = '/tmp/tmp-sandbox/';
78
var GIT_ROOT = SANDBOX_PATH + '.git/';
89
var GIT_HOOKS = GIT_ROOT + 'hooks';
910
var PRECOMMIT_HOOK_PATH = GIT_HOOKS + '/pre-commit';
@@ -16,8 +17,8 @@ function createHook(path, content) {
1617

1718
describe('git-hook runner', function () {
1819
beforeEach(function () {
19-
fsHelpers.makeDir(GIT_ROOT);
20-
gitHooks.install(SANDBOX_PATH);
20+
fsHelpers.makeDir(SANDBOX_PATH);
21+
execSync('git init', {cwd: SANDBOX_PATH});
2122
});
2223

2324
afterEach(function () {

0 commit comments

Comments
 (0)