Produced by Araxis Merge on 10/3/2017 11:52:35 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | job-framework.zip\job-framework\tests\unit\publish-strategies | publish-single-tube-strategy-spec.js | Wed Nov 16 18:40:08 2016 UTC |
| 2 | job-framework.zip\job-framework\tests\unit\publish-strategies | publish-single-tube-strategy-spec.js | Tue Oct 3 16:48:45 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 412 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | var _ = re quire('und erscore'); | |
| 4 | ||
| 5 | var Beanst alkClient = require( '../../../ src/beanst alk-client '); | |
| 6 | var strate gy = requi re('../../ ../src/pub lish-strat egies/publ ish-single -tube-stra tegy'); | |
| 7 | ||
| 8 | var jobSta tusUpdater = { | |
| 9 | create JobStatus: function( job, callb ack) { ret urn callba ck(); }, | |
| 10 | comple teJobStatu s: _.noop, | |
| 11 | startJ obStatus: _.noop, | |
| 12 | errorJ obStatus: _.noop | |
| 13 | }; | |
| 14 | ||
| 15 | var logger = { | |
| 16 | fields : { | |
| 17 | na me: 'dummy -log' | |
| 18 | }, | |
| 19 | child: function( ) { | |
| 20 | re turn this; | |
| 21 | }, | |
| 22 | trace: function( ) {}, | |
| 23 | debug: function( ) {}, | |
| 24 | info: function() {}, | |
| 25 | warn: function() {}, | |
| 26 | error: function( ) {}, | |
| 27 | fatal: function( ) {}, | |
| 28 | consol e: { | |
| 29 | tr ace: conso le.log, | |
| 30 | de bug: conso le.log, | |
| 31 | in fo: consol e.log, | |
| 32 | wa rn: consol e.log, | |
| 33 | er ror: conso le.log, | |
| 34 | fa tal: conso le.log | |
| 35 | } | |
| 36 | }; | |
| 37 | ||
| 38 | describe(' publish-si ngle-tube- strategy.j s', functi on() { | |
| 39 | descri be('publis h', functi on() { | |
| 40 | va r beanstal kClient, p ublisherMo ckInstance , done; | |
| 41 | va r options = {priorit y: 1, dela y: 0, ttr: 120}; | |
| 42 | va r job = {p riority: 6 0}; | |
| 43 | ||
| 44 | be foreEach(f unction() { | |
| 45 | beanstalkC lient = Be anstalkCli ent(logger , ' IP ', 5000); | |
| 46 | ||
| 47 | publishe rMockInsta nce = {log ger: logge r, | |
| 48 | metr ics: {info : function () {}}, | |
| 49 | clie nt: beanst alkClient, | |
| 50 | queu e: undefin ed, | |
| 51 | isCo nnected: f alse, | |
| 52 | bean stalkJobTy peConfig: {tubename: 'single-t ube'} | |
| 53 | }; | |
| 54 | ||
| 55 | publishe rMockInsta nce.connec t = functi on(callbac k) { | |
| 56 | stra tegy.conne ct.call(pu blisherMoc kInstance, callback) ; | |
| 57 | } | |
| 58 | }) ; | |
| 59 | ||
| 60 | it ('job publ ished succ essfully', function( ) { | |
| 61 | spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) { | |
| 62 | retu rn callbac k(); | |
| 63 | }); | |
| 64 | spyOn(be anstalkCli ent, 'use' ).andCallF ake(functi on(tubeNam e, callbac k) { | |
| 65 | retu rn callbac k(null, tu beName); | |
| 66 | }); | |
| 67 | spyOn(be anstalkCli ent, 'put' ).andCallF ake(functi on(priorit y, delay, ttr, job, callback) { | |
| 68 | retu rn callbac k(null, 1) ; | |
| 69 | }); | |
| 70 | ||
| 71 | runs(fun ction() { | |
| 72 | done = false; | |
| 73 | ||
| 74 | stra tegy.publi sh.call(pu blisherMoc kInstance, options, jobStatusU pdater, jo b, functio n(err, res ult) { | |
| 75 | expect(err ).toBeFals y(); | |
| 76 | expect(res ult).toBe( 1); | |
| 77 | done = tru e; | |
| 78 | }) | |
| 79 | }); | |
| 80 | ||
| 81 | waitsFor (function( ) {return done;}, 'D one', 100) ; | |
| 82 | ||
| 83 | runs(fun ction() { | |
| 84 | expe ct(beansta lkClient.c onnect).to HaveBeenCa lled(); | |
| 85 | expe ct(beansta lkClient.u se).toHave BeenCalled (); | |
| 86 | expe ct(beansta lkClient.u se.mostRec entCall.ar gs[0]).toB e('single- tube'); | |
| 87 | expe ct(beansta lkClient.p ut).toHave BeenCalled (); | |
| 88 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[0]).toB e(1); | |
| 89 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[1]).toB e(0); | |
| 90 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[2]).toB e(120); | |
| 91 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[3]).toE qual(JSON. stringify( job)); | |
| 92 | }); | |
| 93 | }) ; | |
| 94 | ||
| 95 | it ('job not published because of an error connecting to beanst alk', func tion() { | |
| 96 | spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) { | |
| 97 | retu rn callbac k('CONNECT ION REFUSE D.'); | |
| 98 | }); | |
| 99 | spyOn(be anstalkCli ent, 'use' ); | |
| 100 | spyOn(be anstalkCli ent, 'put' ); | |
| 101 | ||
| 102 | runs(fun ction() { | |
| 103 | done = false; | |
| 104 | ||
| 105 | stra tegy.publi sh.call(pu blisherMoc kInstance, options, jobStatusU pdater, jo b, functio n(err, res ult) { | |
| 106 | expect(err ).toEqual( 'CONNECTIO N REFUSED. '); | |
| 107 | expect(res ult).toBeF alsy(); | |
| 108 | done = tru e; | |
| 109 | }) | |
| 110 | }); | |
| 111 | ||
| 112 | waitsFor (function( ) {return done;}, 'D one', 100) ; | |
| 113 | ||
| 114 | runs(fun ction() { | |
| 115 | expe ct(beansta lkClient.c onnect).to HaveBeenCa lled(); | |
| 116 | expe ct(beansta lkClient.u se).not.to HaveBeenCa lled(); | |
| 117 | expe ct(beansta lkClient.p ut).not.to HaveBeenCa lled(); | |
| 118 | }); | |
| 119 | }) ; | |
| 120 | ||
| 121 | it ('job not published because of an error selecting the tube i n beanstal k', functi on() { | |
| 122 | spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) { | |
| 123 | retu rn callbac k(); | |
| 124 | }); | |
| 125 | spyOn(be anstalkCli ent, 'use' ).andCallF ake(functi on(tubeNam e, callbac k) { | |
| 126 | retu rn callbac k('INTERNA L ERROR.') ; | |
| 127 | }); | |
| 128 | spyOn(be anstalkCli ent, 'put' ); | |
| 129 | ||
| 130 | runs(fun ction() { | |
| 131 | done = false; | |
| 132 | ||
| 133 | stra tegy.publi sh.call(pu blisherMoc kInstance, options, jobStatusU pdater, jo b, functio n(err, res ult) { | |
| 134 | expect(err ).toEqual( 'INTERNAL ERROR.'); | |
| 135 | expect(res ult).toBeF alsy(); | |
| 136 | done = tru e; | |
| 137 | }) | |
| 138 | }); | |
| 139 | ||
| 140 | waitsFor (function( ) {return done;}, 'D one', 100) ; | |
| 141 | ||
| 142 | runs(fun ction() { | |
| 143 | expe ct(beansta lkClient.c onnect).to HaveBeenCa lled(); | |
| 144 | expe ct(beansta lkClient.u se).toHave BeenCalled (); | |
| 145 | expe ct(beansta lkClient.u se.mostRec entCall.ar gs[0]).toB e('single- tube'); | |
| 146 | expe ct(beansta lkClient.p ut).not.to HaveBeenCa lled(); | |
| 147 | }); | |
| 148 | }) ; | |
| 149 | ||
| 150 | it ('job not published because of an error putting th e job in t he tube on beanstalk ', functio n() { | |
| 151 | spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) { | |
| 152 | retu rn callbac k(); | |
| 153 | }); | |
| 154 | spyOn(be anstalkCli ent, 'use' ).andCallF ake(functi on(tubeNam e, callbac k) { | |
| 155 | retu rn callbac k(null, tu beName); | |
| 156 | }); | |
| 157 | spyOn(be anstalkCli ent, 'put' ).andCallF ake(functi on(priorit y, delay, ttr, job, callback) { | |
| 158 | retu rn callbac k('JOB_TOO _BIG'); | |
| 159 | }); | |
| 160 | ||
| 161 | runs(fun ction() { | |
| 162 | done = false; | |
| 163 | ||
| 164 | stra tegy.publi sh.call(pu blisherMoc kInstance, options, jobStatusU pdater, jo b, functio n(err, res ult) { | |
| 165 | expect(err ).toEqual( 'JOB_TOO_B IG'); | |
| 166 | expect(res ult).toBeF alsy(); | |
| 167 | done = tru e; | |
| 168 | }) | |
| 169 | }); | |
| 170 | ||
| 171 | waitsFor (function( ) {return done;}, 'D one', 100) ; | |
| 172 | ||
| 173 | runs(fun ction() { | |
| 174 | expe ct(beansta lkClient.c onnect).to HaveBeenCa lled(); | |
| 175 | expe ct(beansta lkClient.u se).toHave BeenCalled (); | |
| 176 | expe ct(beansta lkClient.u se.mostRec entCall.ar gs[0]).toB e('single- tube'); | |
| 177 | expe ct(beansta lkClient.p ut).toHave BeenCalled (); | |
| 178 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[0]).toB e(1); | |
| 179 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[1]).toB e(0); | |
| 180 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[2]).toB e(120); | |
| 181 | expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[3]).toE qual(JSON. stringify( job)); | |
| 182 | }); | |
| 183 | }) ; | |
| 184 | ||
| 185 | it ('job publ ished dela yed becaus e connecti on to bean stalk in p rogress', function() { | |
| 186 | var call ed = false ; | |
| 187 | ||
| 188 | spyOn(gl obal, 'set Timeout'). andCallFak e(function (callback, delay) { | |
| 189 | called = t rue; | |
| 190 | } | |
| 191 | ); | |
| 192 | ||
| 193 | publishe rMockInsta nce.isConn ecting = t rue; | |
| 194 | ||
| 195 | runs(fun ction() { | |
| 196 | stra tegy.publi sh.call(pu blisherMoc kInstance, options, jobStatusU pdater, jo b, functio n(err, res ult) { | |
| 197 | }) | |
| 198 | }); | |
| 199 | ||
| 200 | waitsFor (function( ) {return called;}, 'called', 100); | |
| 201 | ||
| 202 | runs(fun ction() { | |
| 203 | expe ct(called) .toBeTruth y(); | |
| 204 | }); | |
| 205 | }) ; | |
| 206 | }); | |
| 207 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.