1 var tap = require('tap')
2 var server = require('./fixtures/server.js')
3 var RC = require('../')
5 { cache: __dirname + '/fixtures/cache'
6 , registry: 'http://localhost:' + server.port
10 , _auth: new Buffer("username:password").toString('base64')
14 var fs = require("fs")
16 tap.test("publish", function (t) {
17 server.expect("/npm-registry-client", function (req, res) {
18 t.equal(req.method, "PUT")
20 req.setEncoding('utf8')
21 req.on("data", function (d) {
25 req.on("end", function () {
27 console.error('PUT req', o)
28 t.equal(o._id, "npm-registry-client")
29 t.equal(o["dist-tags"].latest, pkg.version)
30 t.has(o.versions[pkg.version], pkg)
31 t.same(o.maintainers, [ { name: 'username', email: 'i@izs.me' } ])
32 var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ]
35 res.json({created:true})
39 // not really a tarball, but doesn't matter
40 var tarball = require.resolve('../package.json')
41 var pd = fs.readFileSync(tarball, 'base64')
42 var pkg = require('../package.json')
43 client.publish(pkg, tarball, function (er, data, raw, res) {
45 t.deepEqual(data, { created: true })