Skip to content

Commit

Permalink
maybe ci pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Nov 3, 2016
1 parent b13edc8 commit 9fa211c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
8 changes: 5 additions & 3 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function load (kv) {
tracker.on('moved', function () {
entry.hasTracker = false
const rs = streams.get(key) || []
rs.forEach((stream) => stream.destroy())
rs.forEach((stream) => stream.end())
streams.delete(key)
if (!entry.hasReplicator) {
db.delete(key)
Expand All @@ -52,7 +52,7 @@ function load (kv) {
logger.debug({ key }, 'configuring replicator')
upring.replica(key, function () {
entry.hasReplicator = false
setupTracker(entry, bigError, sendData)
setupTracker(entry, noop, sendData)
})
}

Expand All @@ -79,7 +79,7 @@ function load (kv) {
}
} else {
if (!entry.hasReplicator) {
setupReplicator(entry, bigError, sendData)
setupReplicator(entry, sendData)
}
}

Expand Down Expand Up @@ -191,4 +191,6 @@ function load (kv) {
}
}

function noop () {}

module.exports = load
82 changes: 42 additions & 40 deletions test/multi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ test('get and put', function (t) {
})
})

test('get empty', function (t) {
t.plan(7)

const a = build()
t.tearDown(a.close.bind(a))

a.upring.on('up', function () {
t.pass('a up')
const b = build(a)

t.tearDown(b.close.bind(b))

b.upring.on('up', function () {
t.pass('b up')

b.get('hello', function (err, res) {
t.error(err)
t.equal(res, undefined)

const c = build(a)

t.tearDown(c.close.bind(c))

c.upring.on('up', function () {
t.pass('c up')

c.get('hello', function (err, res) {
t.error(err)
t.equal(res, undefined)
})
})
})
})
})
})

test('moving data', function (t) {
t.plan(13)

Expand Down Expand Up @@ -161,11 +197,13 @@ test('liveUpdates', function (t) {
b.put(key, 'matteo', function (err) {
t.error(err)

b.close(function () {
t.pass('closed')
stream.once('data', function () {
b.close(function () {
t.pass('closed')

a.put(key, 'luca', function (err) {
t.error(err)
a.put(key, 'luca', function (err) {
t.error(err)
})
})
})
})
Expand All @@ -174,39 +212,3 @@ test('liveUpdates', function (t) {
})
})
})

test('get empty', function (t) {
t.plan(7)

const a = build()
t.tearDown(a.close.bind(a))

a.upring.on('up', function () {
t.pass('a up')
const b = build(a)

t.tearDown(b.close.bind(b))

b.upring.on('up', function () {
t.pass('b up')

b.get('hello', function (err, res) {
t.error(err)
t.equal(res, undefined)

const c = build(a)

t.tearDown(c.close.bind(c))

c.upring.on('up', function () {
t.pass('c up')

c.get('hello', function (err, res) {
t.error(err)
t.equal(res, undefined)
})
})
})
})
})
})

0 comments on commit 9fa211c

Please sign in to comment.