Aha, my assumptions were wrong. Change assetions to pass

test/changeset_req-assertions
Marcel Klehr 2013-12-30 18:18:13 +01:00
parent c03c6beb73
commit 31c73203df
1 changed files with 22 additions and 18 deletions

View File

@ -1262,40 +1262,44 @@ function handleChangesetRequest(client, message)
padManager.getPad(message.padId, function(err, pad) { padManager.getPad(message.padId, function(err, pad) {
if(err) return if(err) return
var headRev = pad.getHeadRevisionNumber() var headRev = pad.getHeadRevisionNumber()
, fend = start-(granularity*changesetInfo.forwardsChangesets.length) , end = start+(granularity*changesetInfo.forwardsChangesets.length)-1
, bend = start+(granularity*changesetInfo.backwardsChangesets.length) console.log(changesetInfo)
if(start > headRev || end > headRev) return console.log('Cannot vet from ', start, 'to', end)
if(start > headRev || fend > headRev || bend > headRev) return console.log('Cannot vet from ', start, 'to', end)
pad.getInternalRevisionAText(start, function(err, atextStart) { pad.getInternalRevisionAText(start, function(err, atextStart) {
console.log(start)
ERR(err) ERR(err)
pad.getInternalRevisionAText(fend, function(err, atextFend) { pad.getInternalRevisionAText(end, function(err, atextEnd) {
console.log(end)
ERR(err) ERR(err)
pad.getInternalRevisionAText(bend, function(err, atextBend) {
ERR(err)
console.log(changesetInfo)
// check forward // check forward
console.log('Vetting revision path from ', fend, 'to', start) console.log('Vetting revision path from ', start, 'to', end)
var atext = atextFend var atext = atextStart
console.log(atext)
if(changesetInfo.forwardsChangesets.length > headRev-1) changesetInfo.forwardsChangesets.shift() // remove the first changeset, as we already have the first revision.
changesetInfo.forwardsChangesets.forEach(function(cs) { changesetInfo.forwardsChangesets.forEach(function(cs) {
atext = Changeset.applyToAText(cs, atext) atext = Changeset.applyToAText(cs, atext)
}) })
assert(atext.text == atextStart.text) console.log(atext)
assert(atext.attribs == atextStart.attribs) console.log(atextEnd)
assert(atext.text == atextEnd.text)
console.log('OK') console.log('OK')
// check backward /*/ // check backward /*/
console.log('Vetting revision path from ', bend, 'to', start) console.log('Vetting revision path from ', end, 'to', start)
atext = atextBend atext = atextEnd
changesetInfo.backwardsChangesets.forEach(function(cs) { console.log(atextEnd)
if(changesetInfo.backwardsChangesets.length > headRev-1) changesetInfo.backwardsChangesets.shift()
changesetInfo.backwardsChangesets.reverse().forEach(function(cs) {
atext = Changeset.applyToAText(cs, atext) atext = Changeset.applyToAText(cs, atext)
}) })
console.log(atext)
console.log(atextStart)
assert(atext.text == atextStart.text) assert(atext.text == atextStart.text)
assert(atext.attribs == atextStart.attribs)
console.log('OK') console.log('OK')
})
}) })
}) })
}) })