|
|
|
@ -108,6 +108,135 @@ t.describe('#getLatestVersion()', function() {
|
|
|
|
|
assert.match(err.message, /found/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should return correct name and link in result when git_required_prefix is specified', async function() {
|
|
|
|
|
const assertName = 'Karen'
|
|
|
|
|
const assertLink = 'Over The Future'
|
|
|
|
|
const assertFilename = 'gittest_test-sc.7z'
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({ git_required_prefix: 'gittest' }, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: assertName, assets: [{ name: assertFilename, browser_download_url: assertLink }] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let version = await provider.getLatestVersion()
|
|
|
|
|
assert.strictEqual(version.version, assertName)
|
|
|
|
|
assert.strictEqual(version.link, assertLink)
|
|
|
|
|
assert.strictEqual(version.filename, assertFilename)
|
|
|
|
|
assert.strictEqual(version.log, '')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should skip zip files for now even when git_required_prefix is specified', async function() {
|
|
|
|
|
const assertName = 'Karen'
|
|
|
|
|
const assertLink = 'My Wings'
|
|
|
|
|
const assertFilename = 'gittest_test-sc.zip'
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({ git_required_prefix: 'gittest' }, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: assertName, assets: [{ name: assertFilename, browser_download_url: assertLink }] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let err = await assert.isRejected(provider.getLatestVersion())
|
|
|
|
|
assert.match(err.message, /release/)
|
|
|
|
|
assert.match(err.message, /found/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should skip versions with missing git_required_prefix prefix', async function() {
|
|
|
|
|
const assertName = 'name1'
|
|
|
|
|
const assertLink = 'somelink'
|
|
|
|
|
const assertFilename = 'gittest_something-sc.7z'
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({ git_required_prefix: 'gittest' }, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: 'test', assets: [] },
|
|
|
|
|
{ name: assertName, assets: [{ name: 'something-sc.7z', browser_download_url: 'nope' }] },
|
|
|
|
|
{ name: assertName, assets: [{ name: assertFilename, browser_download_url: assertLink }] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let version = await provider.getLatestVersion()
|
|
|
|
|
assert.strictEqual(version.version, assertName)
|
|
|
|
|
assert.strictEqual(version.link, assertLink)
|
|
|
|
|
assert.strictEqual(version.filename, assertFilename)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should skip versions with non-sc, non-git_required_prefix filename', async function() {
|
|
|
|
|
const assertName = 'name2'
|
|
|
|
|
const assertLink = 'somelink2'
|
|
|
|
|
const assertFilename = 'gittest_something-sc.7z'
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({ git_required_prefix: 'gittest' }, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: 'test', assets: [{ name: 'nope.7z', browser_download_url: 'nope' }] },
|
|
|
|
|
{ name: 'test', assets: [{ name: 'gittest_nope.7z', browser_download_url: 'nope' }] },
|
|
|
|
|
{ name: assertName, assets: [{ name: assertFilename, browser_download_url: assertLink }] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let version = await provider.getLatestVersion()
|
|
|
|
|
assert.strictEqual(version.version, assertName)
|
|
|
|
|
assert.strictEqual(version.link, assertLink)
|
|
|
|
|
assert.strictEqual(version.filename, assertFilename)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should skip assets with non-sc filename and non-git_required_prefix', async function() {
|
|
|
|
|
const assertName = 'name3'
|
|
|
|
|
const assertLink = 'somelink3'
|
|
|
|
|
const assertFilename = 'gittest_something-sc.7z'
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({ git_required_prefix: 'gittest' }, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: 'test', assets: [{ name: 'gittest_nope.7z', browser_download_url: 'nope' }] },
|
|
|
|
|
{ name: assertName, assets: [
|
|
|
|
|
{ name: 'nope.7z', browser_download_url: 'nope' },
|
|
|
|
|
{ name: 'gittest_nope.7z', browser_download_url: 'nope' },
|
|
|
|
|
{ name: 'something-sc.7z', browser_download_url: 'nope' },
|
|
|
|
|
{ name: assertFilename, browser_download_url: assertLink },
|
|
|
|
|
] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let version = await provider.getLatestVersion()
|
|
|
|
|
assert.strictEqual(version.version, assertName)
|
|
|
|
|
assert.strictEqual(version.link, assertLink)
|
|
|
|
|
assert.strictEqual(version.filename, assertFilename)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should otherwise reject non-git_required_prefix files', async function() {
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({ git_required_prefix: 'gittest' }, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: 'test', assets: [{ name: 'nope.7z', browser_download_url: 'nope' }] },
|
|
|
|
|
{ name: 'test2', assets: [{ name: 'nope2.7z', browser_download_url: 'nope' },] },
|
|
|
|
|
{ name: 'test3', assets: [{ name: 'nope2.7z', browser_download_url: 'nope' },] },
|
|
|
|
|
{ name: 'test3', assets: [{ name: 'something-sc.7z', browser_download_url: 'nope' },] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let err = await assert.isRejected(provider.getLatestVersion())
|
|
|
|
|
assert.match(err.message, /release/)
|
|
|
|
|
assert.match(err.message, /found/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should otherwise reject', async function() {
|
|
|
|
|
let stubber = stub()
|
|
|
|
|
let provider = new GitProvider({}, stubber)
|
|
|
|
|
|
|
|
|
|
stubber.resolves({ body: [
|
|
|
|
|
{ name: 'test', assets: [{ name: 'nope.7z', browser_download_url: 'nope' }] },
|
|
|
|
|
{ name: 'test2', assets: [{ name: 'nope2.7z', browser_download_url: 'nope' },] },
|
|
|
|
|
{ name: 'test3', assets: [{ name: 'nope2.7z', browser_download_url: 'nope' },] },
|
|
|
|
|
]})
|
|
|
|
|
|
|
|
|
|
let err = await assert.isRejected(provider.getLatestVersion())
|
|
|
|
|
assert.match(err.message, /release/)
|
|
|
|
|
assert.match(err.message, /found/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.test('should reject if not valid body', async function() {
|
|
|
|
|
let provider = new GitProvider({}, stub())
|
|
|
|
|
|
|
|
|
|