Skip to content

Commit

Permalink
test: execFile incompatible on Windows with mock-git
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jul 12, 2020
1 parent 871201f commit 7196008
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 71 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -60,7 +60,6 @@
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"mocha": "7.2.0",
"mock-git": "2.0.0",
"mockery": "2.1.0",
"nyc": "14.1.1",
"shelljs": "0.8.4"
Expand Down
70 changes: 0 additions & 70 deletions test.js
Expand Up @@ -6,7 +6,6 @@ const shell = require('shelljs')
const fs = require('fs')
const path = require('path')
const stream = require('stream')
const mockGit = require('mock-git')
const mockery = require('mockery')
const semver = require('semver')
const formatCommitMessage = require('./lib/format-commit-message')
Expand Down Expand Up @@ -248,75 +247,6 @@ describe('cli', function () {
})
})

describe('with mocked git', function () {
it('--sign signs the commit and tag', function () {
// mock git with file that writes args to gitcapture.log
return mockGit('require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")')
.then(function (unmock) {
execCli('--sign').code.should.equal(0)

const captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) {
return line ? JSON.parse(line) : line
})
/* eslint-disable no-useless-escape */
captured[captured.length - 4].should.deep.equal(['commit', '-S', 'CHANGELOG.md', 'package.json', '-m', '\"chore(release): 1.0.1\"'])
captured[captured.length - 3].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', '\"chore(release): 1.0.1\"'])
/* eslint-enable no-useless-escape */
unmock()
})
})

it('exits with error code if git commit fails', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("commit yourself"); process.exit(128);', 'commit')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/commit yourself/)

unmock()
})
})

it('exits with error code if git add fails', function () {
// mock git by throwing on attempt to add
return mockGit('console.error("addition is hard"); process.exit(128);', 'add')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/addition is hard/)

unmock()
})
})

it('exits with error code if git tag fails', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("tag, you\'re it"); process.exit(128);', 'tag')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/tag, you're it/)

unmock()
})
})

it('doesn\'t fail fast on stderr output from git', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("haha, kidding, this is just a warning"); process.exit(0);', 'add')
.then(function (unmock) {
writePackageJson('1.0.0')

const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/haha, kidding, this is just a warning/)

unmock()
})
})
})

describe('lifecycle scripts', () => {
describe('prerelease hook', function () {
it('should run the prerelease hook when provided', function () {
Expand Down

0 comments on commit 7196008

Please sign in to comment.