Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AAE471165F for ; Fri, 20 Jun 2014 21:51:16 +0000 (UTC) Received: (qmail 26176 invoked by uid 500); 20 Jun 2014 21:51:16 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 25919 invoked by uid 500); 20 Jun 2014 21:51:16 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 25829 invoked by uid 99); 20 Jun 2014 21:51:16 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jun 2014 21:51:16 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id EB23298918E; Fri, 20 Jun 2014 21:51:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: commits@cordova.apache.org Date: Fri, 20 Jun 2014 21:51:16 -0000 Message-Id: <080ce92e336b43c9b0c4eaf9e4deeeb1@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: Add tests for fetch.checkID() Add tests for fetch.checkID() Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/f6584895 Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/f6584895 Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/f6584895 Branch: refs/heads/master Commit: f6584895a6136d865aa26ac27de88b0f5e080c10 Parents: 4cccc6a Author: Vladimir Kotikov Authored: Mon May 5 10:02:26 2014 +0400 Committer: Vladimir Kotikov Committed: Mon May 5 10:02:26 2014 +0400 ---------------------------------------------------------------------- spec/fetch.spec.js | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/f6584895/spec/fetch.spec.js ---------------------------------------------------------------------- diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js index 2a0b660..6613865 100644 --- a/spec/fetch.spec.js +++ b/spec/fetch.spec.js @@ -23,7 +23,7 @@ describe('fetch', function() { var xml, rm, sym, mkdir, cp, save_metadata; beforeEach(function() { xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({ - getroot:function() { return {attrib:{id:'id'}};} + getroot:function() { return {attrib:{id:'id', version:'version'}};} }); rm = spyOn(shell, 'rm'); sym = spyOn(fs, 'symlinkSync'); @@ -62,6 +62,19 @@ describe('fetch', function() { expect(1).toBe(1); }); }); + it('should fail when the expected ID with version specified doesn\'t match', function(done) { + fetch(test_plugin, temp, { expected_id: 'id@wrongVersion' }) + .then(function() { + expect('this call').toBe('fail'); + }, function(err) { + expect(''+err).toContain('Expected fetched plugin to have ID "id@wrongVersion" but got "id@version".'); + }).fin(done); + }); + it('should succeed when the plugin version specified is correct', function(done) { + wrapper(fetch(test_plugin, temp, { expected_id: 'id@version' }), done, function() { + expect(1).toBe(1); + }); + }); }); describe('git plugins', function() { var clone, save_metadata, done, xml; @@ -75,7 +88,7 @@ describe('fetch', function() { save_metadata = spyOn(metadata, 'save_fetch_metadata'); done = false; xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({ - getroot:function() { return {attrib:{id:'id'}};} + getroot:function() { return {attrib:{id:'id', version:'version'}};} }); }); it('should call clonePluginGitRepo for https:// and git:// based urls', function() { @@ -168,18 +181,31 @@ describe('fetch', function() { expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".'); }).fin(done); }); + it('should fail when the expected ID with version specified doesn\'t match', function(done) { + fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id@wrongVersion' }) + .then(function() { + expect('this call').toBe('fail'); + }, function(err) { + expect(''+err).toContain('Expected fetched plugin to have ID "id@wrongVersion" but got "id@version".'); + }).fin(done); + }); it('should succeed when the expected ID is correct', function(done) { wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id' }), done, function() { expect(1).toBe(1); }); }); + it('should succeed when the plugin version specified is correct', function(done) { + wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id@version' }), done, function() { + expect(1).toBe(1); + }); + }); }); describe('registry plugins', function() { var pluginId = 'dummyplugin', sFetch; var xml, rm, sym, mkdir, cp, save_metadata; beforeEach(function() { xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({ - getroot:function() { return {attrib:{id:'id'}};} + getroot:function() { return {attrib:{id:'id', version:'version'}};} }); rm = spyOn(shell, 'rm'); sym = spyOn(fs, 'symlinkSync'); @@ -202,10 +228,23 @@ describe('fetch', function() { expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".'); }).fin(done); }); + it('should fail when the expected ID with version specified doesn\'t match', function(done) { + fetch(pluginId, temp, { expected_id: 'id@wrongVersion' }) + .then(function() { + expect('this call').toBe('fail'); + }, function(err) { + expect(''+err).toContain('Expected fetched plugin to have ID "id@wrongVersion" but got "id@version".'); + }).fin(done); + }); it('should succeed when the expected ID is correct', function(done) { wrapper(fetch(pluginId, temp, { expected_id: 'id' }), done, function() { expect(1).toBe(1); }); }); + it('should succeed when the plugin version specified is correct', function(done) { + wrapper(fetch(pluginId, temp, { expected_id: 'id@version' }), done, function() { + expect(1).toBe(1); + }); + }); }); });