|
| 1 | +/* |
| 2 | + Used to test the gitlab worker |
| 3 | + */ |
| 4 | + |
| 5 | +var proxyquire = require('proxyquire'); |
| 6 | +var expect = require('expect.js'); |
| 7 | +var util = require('util'); |
| 8 | +var debug = require('debug')('strider-gitlab:test:webapp'); |
| 9 | + |
| 10 | +var gitStub = { }; |
| 11 | + |
| 12 | +gitStub.fetch = function(dest, config, job, context, done) { |
| 13 | + done(); |
| 14 | +} |
| 15 | + |
| 16 | +var worker = proxyquire('../lib/worker', {'strider-git/worker': gitStub}); |
| 17 | + |
| 18 | +describe('gitlab worker', function () { |
| 19 | + //-------------------------------------------------------------------------------------- |
| 20 | + describe('init', function () { |
| 21 | + var dirs = { |
| 22 | + base: '/home/dev/.strider', |
| 23 | + data: '/home/dev/.strider/data/stridertester-privproject1-55de9a6c1cfc0d872d309dbb', |
| 24 | + cache: '/home/dev/.strider/cache/stridertester/privproject1' |
| 25 | + }; |
| 26 | + |
| 27 | + var account = { |
| 28 | + api_url: 'http://localhost:80/api/v3', |
| 29 | + api_key: 'zRtVsmeznn7ySatTrnrp' |
| 30 | + }; |
| 31 | + |
| 32 | + var config = { |
| 33 | + whitelist: [], |
| 34 | + pull_requests: 'none', |
| 35 | + repo: 'http://nodev/stridertester/privproject1', |
| 36 | + owner: { |
| 37 | + avatar_url: 'http://www.gravatar.com/avatar/3f671ed86ed3d21ed3640c7a016b0997?s=40&d=identicon', |
| 38 | + state: 'active', |
| 39 | + id: 3, |
| 40 | + username: 'stridertester', |
| 41 | + name: 'Strider Tester' |
| 42 | + }, |
| 43 | + url: 'git@nodev:stridertester/privproject1.git', |
| 44 | + scm: 'git', |
| 45 | + auth: { type: 'ssh' } |
| 46 | + }; |
| 47 | + |
| 48 | + var job = { }; |
| 49 | + |
| 50 | + it('should call back with err as null and the second param as an object with three properties, config, account and a fetch function', function(done) { |
| 51 | + worker.init(dirs, account, config, job, function(err, object) { |
| 52 | + expect(err).to.not.be.ok(); |
| 53 | + expect(object.config).to.eql(config); |
| 54 | + expect(object.account).to.eql(account); |
| 55 | + expect(object.fetch).to.be.a('function'); |
| 56 | + done(); |
| 57 | + }); |
| 58 | + }); |
| 59 | + |
| 60 | + it('should check for invalid arguments and operational errors ?'); |
| 61 | + }); |
| 62 | + |
| 63 | + //-------------------------------------------------------------------------------------- |
| 64 | + describe('fetch', function () { |
| 65 | + |
| 66 | + it('should call our callback after strider-git/worker fetch is done with its task', function(done){ |
| 67 | + var dest = ""; |
| 68 | + var account = { |
| 69 | + accessToken: "abcd" |
| 70 | + }; |
| 71 | + var config = { |
| 72 | + auth: { |
| 73 | + type : "https", |
| 74 | + username: "strider" |
| 75 | + } |
| 76 | + }; |
| 77 | + var job = {}; |
| 78 | + var context = {}; |
| 79 | + |
| 80 | + worker.fetch(dest, account, config, job, context, done); |
| 81 | + }); |
| 82 | + |
| 83 | + it('should check for invalid arguments and operational errors ?'); |
| 84 | + }); |
| 85 | + |
| 86 | +}); |
0 commit comments