1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
var createReadStream = require('fs').createReadStream
var test = require('tap').test
var server = require('./lib/server.js')
var common = require('./lib/common.js')
var config = { retry: { retries: 0 } }
var client = common.freshClient(config)
var URI = 'http://localhost:1337/'
var USERNAME = 'username'
var PASSWORD = '%1234@asdf%'
var EMAIL = 'i@izs.me'
var METADATA = require('../package.json')
var ACCESS = 'public'
// not really a tarball, but doesn't matter
var BODY_PATH = require.resolve('../package.json')
var BODY = createReadStream(BODY_PATH)
var AUTH = {
username: USERNAME,
password: PASSWORD,
email: EMAIL
}
var PARAMS = {
metadata: METADATA,
access: ACCESS,
body: BODY,
auth: AUTH
}
test('publish with a 500 response but no message', function (t) {
server.expect('/npm-registry-client', function (req, res) {
res.statusCode = 500
res.json({ success: false })
})
client.publish(URI, PARAMS, function (er, data) {
t.ok(er, 'got expected error')
t.notOk(data, 'no payload on failure')
t.end()
})
})
|