Skip to content

Commit

Permalink
add missing asset names to 404 output. #45
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed May 15, 2018
1 parent 2f24074 commit 6daaef2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ class Updates {
const latest = await this.cachedGetLatest(account, repository, platform)

if (!latest) {
notFound(res)
const message =
platform === 'darwin'
? 'No updates found (needs asset matching *{mac,darwin,osx}*.zip)'
: 'No updates found (needs asset containing win32-x64 or .exe)'
notFound(res, message)
} else if (semver.eq(latest.version, version)) {
log.info({ account, repository, platform, version }, 'up to date')
noContent(res)
Expand Down
42 changes: 32 additions & 10 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,29 @@ test('Updates', async t => {

await t.test('Platforms', async t => {
await t.test('Darwin', async t => {
for (let i = 0; i < 2; i++) {
let res = await fetch(`${address}/owner/repo/darwin/0.0.0`)
t.equal(res.status, 200)
let body = await res.json()
t.equal(body.url, 'mac.zip')
await t.test('.zip', async t => {
for (let i = 0; i < 2; i++) {
let res = await fetch(`${address}/owner/repo/darwin/0.0.0`)
t.equal(res.status, 200)
let body = await res.json()
t.equal(body.url, 'mac.zip')

res = await fetch(`${address}/owner/repo-darwin/darwin/0.0.0`)
t.equal(res.status, 200)
body = await res.json()
t.match(body.url, 'darwin.zip')
}
res = await fetch(`${address}/owner/repo-darwin/darwin/0.0.0`)
t.equal(res.status, 200)
body = await res.json()
t.match(body.url, 'darwin.zip')
}
})

await t.test('missing asset', async t => {
const res = await fetch(`${address}/owner/repo-win32-zip/darwin/0.0.0`)
t.equal(res.status, 404)
const body = await res.text()
t.equal(
body,
'No updates found (needs asset matching *{mac,darwin,osx}*.zip)'
)
})
})

await t.test('Win32', async t => {
Expand Down Expand Up @@ -261,6 +273,16 @@ test('Updates', async t => {
t.equal(res.status, 404)
}
})

await t.test('missing asset', async t => {
const res = await fetch(`${address}/owner/repo-darwin/win32/0.0.0`)
t.equal(res.status, 404)
const body = await res.text()
t.equal(
body,
'No updates found (needs asset containing win32-x64 or .exe)'
)
})
})

await t.test('Linux', async t => {
Expand Down

0 comments on commit 6daaef2

Please sign in to comment.