2014-11-12 12:14:37 +01:00
|
|
|
var assert = require('assert')
|
|
|
|
var semver_sort = require('../../lib/utils').semver_sort
|
|
|
|
var merge = require('../../lib/storage')._merge_versions
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2013-12-21 13:09:29 +01:00
|
|
|
require('../../lib/logger').setup([])
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2013-12-19 16:11:54 +01:00
|
|
|
describe('Merge', function() {
|
2014-11-12 12:14:37 +01:00
|
|
|
it('simple', function() {
|
|
|
|
var x = {
|
|
|
|
versions: {a:1,b:1,c:1},
|
|
|
|
'dist-tags': {},
|
|
|
|
}
|
|
|
|
merge(x, {versions: {a:2,q:2}})
|
|
|
|
assert.deepEqual(x, {
|
|
|
|
versions: {a:1,b:1,c:1,q:2},
|
|
|
|
'dist-tags': {},
|
|
|
|
})
|
|
|
|
})
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('dist-tags - compat', function() {
|
|
|
|
var x = {
|
|
|
|
versions: {},
|
2016-04-18 21:53:00 +02:00
|
|
|
'dist-tags': {q:'1.1.1',w:'2.2.2'},
|
2014-11-12 12:14:37 +01:00
|
|
|
}
|
|
|
|
merge(x, {'dist-tags':{q:'2.2.2',w:'3.3.3',t:'4.4.4'}})
|
|
|
|
assert.deepEqual(x, {
|
|
|
|
versions: {},
|
2016-04-18 21:53:00 +02:00
|
|
|
'dist-tags': {q:'2.2.2',w:'3.3.3',t:'4.4.4'},
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
})
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('semver_sort', function() {
|
|
|
|
assert.deepEqual(semver_sort(['1.2.3','1.2','1.2.3a','1.2.3c','1.2.3-b']),
|
|
|
|
[ '1.2.3a',
|
|
|
|
'1.2.3-b',
|
|
|
|
'1.2.3c',
|
|
|
|
'1.2.3' ]
|
|
|
|
)
|
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
})
|
2013-12-11 21:51:48 +01:00
|
|
|
|