Skip to content

Commit

Permalink
fix discovery test
Browse files Browse the repository at this point in the history
  • Loading branch information
mstdokumaci committed Nov 29, 2016
1 parent ba2ad1e commit fadd967
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/fleet.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,24 @@ test('services - deploy all successfuly', t => {
})

test('services - discover services', t => {
const s4New = { name: 's4', version: '2', env: 'a=b&c=d', url: 'u11.sh', created: 12 }
const s3New = { name: 's3', version: '1', env: 'a=b&c=d', url: 'u12.sh', created: 12 }
const s4New = { 11: { id: '11', name: 's4', url: 'u11.sh', created: 12, pkg: { version: '2', env: 'a=b&c=d', routes: {}, wrapper: {} } } }
const s3New = { 12: { id: '12', name: 's3', url: 'u12.sh', created: 12, pkg: { version: '1', env: 'a=b&c=d', routes: {}, wrapper: {} } } }

const subscribe = sinon.stub(Hub.prototype, 'subscribe')
const get = sinon.stub(Hub.prototype, 'get')

subscribe
.withArgs({ deployments: { val: true } })
.callsArg(1)

get
.withArgs('deployments')
.onFirstCall()
.returns(registryDeployments)
.onSecondCall()
.returns(registryDeployments.set(s4New))
.onThirdCall()
.returns(registryDeployments.set(s3New))

var pkg = {
_services: {
Expand All @@ -309,7 +325,7 @@ test('services - discover services', t => {
_env: 'a=b&c=d'
}

fleet.discoverAll(pkg, 0)
fleet.getServices(pkg, 1)
.then((pkg) => {
t.deepEqual(pkg._services, {
's2': 'u8.sh',
Expand All @@ -318,6 +334,7 @@ test('services - discover services', t => {
}, 'services should be discovered as expected')
t.end()

registry.getList.restore()
subscribe.restore()
get.restore()
})
})

0 comments on commit fadd967

Please sign in to comment.