2013-12-07 17:55:50 -05:00
|
|
|
var assert = require('assert')
|
2013-12-15 15:54:50 -05:00
|
|
|
, semver_sort = require('../../lib/storage')._semver_sort
|
|
|
|
, merge = require('../../lib/storage')._merge_versions
|
2013-12-07 17:55:50 -05:00
|
|
|
|
|
|
|
//require('../lib/logger').setup()
|
|
|
|
|
|
|
|
exports['Merge'] = {
|
|
|
|
'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': {},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
'dist-tags - compat': function() {
|
|
|
|
var x = {
|
|
|
|
versions: {},
|
|
|
|
'dist-tags': {q:'1.1.1',w:['2.2.2']},
|
|
|
|
}
|
|
|
|
merge(x, {'dist-tags':{q:'2.2.2',w:'3.3.3',t:'4.4.4'}})
|
|
|
|
assert.deepEqual(x, {
|
|
|
|
versions: {},
|
|
|
|
'dist-tags': {q:['1.1.1','2.2.2'],w:['2.2.2','3.3.3'],t:['4.4.4']},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
'dist-tags - sort': function() {
|
|
|
|
var x = {
|
|
|
|
versions: {},
|
|
|
|
'dist-tags': {w:['2.2.2','1.1.1','12.2.2','2.2.2-rc2']},
|
|
|
|
}
|
|
|
|
merge(x, {'dist-tags':{w:'3.3.3'}})
|
|
|
|
assert.deepEqual(x, {
|
|
|
|
versions: {},
|
|
|
|
'dist-tags': {w:["1.1.1","2.2.2-rc2","2.2.2","3.3.3","12.2.2"]},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2013-12-11 16:22:35 -05:00
|
|
|
'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-11 15:51:48 -05:00
|
|
|
}
|
|
|
|
|