From f0787d4d51a6e58c9f79bf5236b7cdaa54296818 Mon Sep 17 00:00:00 2001 From: Mikito Takada Date: Sat, 6 Dec 2014 10:10:11 -0800 Subject: [PATCH] Add test for folder with spaces in the name --- plugins/bootstrap.js | 3 --- test/gr.test.js | 39 +++++++++++++++++++++++++++++++- test/integration.tagging.test.js | 38 +++++++++++++++---------------- 3 files changed, 57 insertions(+), 23 deletions(-) delete mode 100644 plugins/bootstrap.js diff --git a/plugins/bootstrap.js b/plugins/bootstrap.js deleted file mode 100644 index e4f8c9e..0000000 --- a/plugins/bootstrap.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function(req, res, next) { - -}; diff --git a/test/gr.test.js b/test/gr.test.js index afb578a..34d7c47 100644 --- a/test/gr.test.js +++ b/test/gr.test.js @@ -51,12 +51,49 @@ describe('gr integration tests', function() { run(fixturepath + '/a' + ' node ' + utilpath + '/bin/echoback.js ' + ' "foo bar"', fixturepath + '/a', function(result) { - console.log(result); assert.ok(/\[ 'foo bar' \]/.test(result)); done(); }); }); + describe('path with spaces', function() { + var fixturepath = fs.realpathSync(fixture.dir({ + 'this path has spaces/file.txt': 'file.txt' + })); + + it('can tag a folder using quotes', function(done) { + var tag = Math.random().toString(36).substring(2), + expected = fixturepath + '/this path has spaces'; + + run('--json +@' + tag + ' "' + expected + '"', fixturepath, function(result) { + // get the answer + run('--json tag ls ' + tag, fixturepath, function(result) { + assert.ok(Array.isArray(result)); + assert.ok(result.some(function(v) { + return v == expected; + })); + done(); + }); + }); + }); + + it('can tag a folder using escaped spaces', function(done) { + var tag = Math.random().toString(36).substring(2), + expected = fixturepath + '/this path has spaces'; + + run('--json +@' + tag + ' ' + expected.replace(/ /g, '\\ '), fixturepath, function(result) { + // get the answer + run('--json tag ls ' + tag, fixturepath, function(result) { + assert.ok(Array.isArray(result)); + assert.ok(result.some(function(v) { + return v == expected; + })); + done(); + }); + }); + }); + }); + // Not worth testing automatically: // gr tag discover Auto-discover git paths under ~/ diff --git a/test/integration.tagging.test.js b/test/integration.tagging.test.js index 587fc18..2692a58 100644 --- a/test/integration.tagging.test.js +++ b/test/integration.tagging.test.js @@ -29,21 +29,21 @@ describe('integration tagging', function() { after(function() { restore(); }); - // Tagging: + describe('pristine - ', function() { beforeEach(function(done) { // add a new random tag this.pristineTag = Math.random().toString(36).substring(2); - run('--json +#' + this.pristineTag, fixturepath + '/a', function(result) { + run('--json +@' + this.pristineTag, fixturepath + '/a', function(result) { done(); }); }); - it('#tag - List directories associated with "tag"', function(done) { + it('@tag - List directories associated with "tag"', function(done) { var p = fixturepath + '/a'; - // #foo + // @foo run('--json -t ' + this.pristineTag, p, function(result) { assert.ok(Array.isArray(result)); assert.ok(result.some(function(v) { @@ -53,9 +53,9 @@ describe('integration tagging', function() { }); }); - // #tag Run a command in the directories associated with "tag" + // @tag Run a command in the directories associated with "tag" it('-t - Run a command in the directories associated with "tag"', function(done) { - // #foo ls -lah + // @foo ls -lah run('-t ' + this.pristineTag + ' ls -lah', fixturepath + '/a', function(result) { // check that one of the lines contains "a.txt" assert.ok(/a\.txt/.test(result)); @@ -87,12 +87,12 @@ describe('integration tagging', function() { }); }); - it('-#tag - Remove a tag from the current directory (cwd)', function(done) { + it('-@tag - Remove a tag from the current directory (cwd)', function(done) { var p = fixturepath + '/a', tag = this.pristineTag; - // -#foo + // -@foo // tag rm foo - run('--json -#' + tag, p, function(result) { + run('--json -@' + tag, p, function(result) { assert.deepEqual(result, { op: 'rm', tag: tag, path: p }); run('--json tag ls ' + tag, p, function(result) { assert.ok(Array.isArray(result)); @@ -104,7 +104,7 @@ describe('integration tagging', function() { }); }); - it('tag rm - Alternative to -#tag', function(done) { + it('tag rm - Alternative to -@tag', function(done) { var p = fixturepath + '/b', tag = this.pristineTag; run('--json tag rm ' + tag, p, function(result) { @@ -116,10 +116,10 @@ describe('integration tagging', function() { }); - it('+#tag - Add a tag to the current directory (cwd)', function(done) { + it('+@tag - Add a tag to the current directory (cwd)', function(done) { var p = fixturepath + '/a', tag = Math.random().toString(36).substring(2); - run('--json +#' + tag, p, function(result) { + run('--json +@' + tag, p, function(result) { // get the answer run('--json tag ls ' + tag, p, function(result) { assert.ok(Array.isArray(result)); @@ -131,7 +131,7 @@ describe('integration tagging', function() { }); }); - it('tag add - Alternative to +#tag (cwd)', function(done) { + it('tag add - Alternative to +@tag (cwd)', function(done) { var p = fixturepath + '/b', tag = Math.random().toString(36).substring(2); run('--json tag add ' + tag, p, function(result) { @@ -157,10 +157,10 @@ describe('integration tagging', function() { this.pristineTag = Math.random().toString(36).substring(2); }); - it('+#tag ... Add a tag to ', function(done) { + it('+@tag ... Add a tag to ', function(done) { var self = this, p = fixturepath + '/a'; - run('--json +#' + this.pristineTag + ' ' + this.dirs.join(' '), p, function(result) { + run('--json +@' + this.pristineTag + ' ' + this.dirs.join(' '), p, function(result) { // get the answer run('--json tag ls ' + self.pristineTag, p, function(result) { @@ -174,7 +174,7 @@ describe('integration tagging', function() { }); }); - it('tag add ... Alternative to +#tag ', function(done) { + it('tag add ... Alternative to +@tag ', function(done) { var self = this, p = fixturepath + '/a'; run('--json tag add ' + this.pristineTag + ' ' + this.dirs.join(' '), p, function(result) { @@ -190,11 +190,11 @@ describe('integration tagging', function() { }); }); - // -#tag Remove a tag from - // tag rm

Alternative to -#tag + // -@tag Remove a tag from + // tag rm

Alternative to -@tag // TODO - // gr -#foo path1 path2 path3 + // gr -@foo path1 path2 path3 // TODO });