summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/test
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-12-16 16:23:13 -0800
committerisaacs <i@izs.me>2013-12-16 23:09:16 -0800
commit97738994e0bc2f3255659ca8f27e43a90aa0a24e (patch)
tree51bc3a3a928ddcba4944b8294656158d120d3d75 /deps/npm/node_modules/npm-registry-client/test
parent39e2426b209799d5deaa29d2401dd98f060babda (diff)
downloadnode-97738994e0bc2f3255659ca8f27e43a90aa0a24e.tar.gz
npm: Upgrade to 1.3.19
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/test')
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/fixtures/server.js4
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/publish-again.js81
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/publish.js48
3 files changed, 131 insertions, 2 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/test/fixtures/server.js b/deps/npm/node_modules/npm-registry-client/test/fixtures/server.js
index 468a89e5b..80bbf4803 100644
--- a/deps/npm/node_modules/npm-registry-client/test/fixtures/server.js
+++ b/deps/npm/node_modules/npm-registry-client/test/fixtures/server.js
@@ -17,10 +17,10 @@ function handler (req, res) {
, mu = req.method + ' ' + req.url
var k = server._expect[mu] ? mu : server._expect[u] ? u : null
- if (!k) throw Error('unexpected request', req.method, req.url)
+ if (!k) throw Error('unexpected request: ' + req.method + ' ' + req.url)
var fn = server._expect[k].shift()
- if (!fn) throw Error('unexpected request', req.method, req.url)
+ if (!fn) throw Error('unexpected request' + req.method + ' ' + req.url)
var remain = (Object.keys(server._expect).reduce(function (s, k) {
diff --git a/deps/npm/node_modules/npm-registry-client/test/publish-again.js b/deps/npm/node_modules/npm-registry-client/test/publish-again.js
new file mode 100644
index 000000000..0170a6f3a
--- /dev/null
+++ b/deps/npm/node_modules/npm-registry-client/test/publish-again.js
@@ -0,0 +1,81 @@
+var tap = require('tap')
+var server = require('./fixtures/server.js')
+var RC = require('../')
+var client = new RC(
+ { cache: __dirname + '/fixtures/cache'
+ , registry: 'http://localhost:' + server.port
+ , username: "username"
+ , password: "password"
+ , email: "i@izs.me"
+ , _auth: new Buffer("username:password").toString('base64')
+ , "always-auth": true
+ })
+
+var fs = require("fs")
+
+tap.test("publish again", function (t) {
+ var lastTime = null
+ server.expect("/npm-registry-client", function (req, res) {
+ t.equal(req.method, "PUT")
+ var b = ""
+ req.setEncoding('utf8')
+ req.on("data", function (d) {
+ b += d
+ })
+
+ req.on("end", function () {
+ var o = lastTime = JSON.parse(b)
+ t.equal(o._id, "npm-registry-client")
+ t.equal(o["dist-tags"].latest, pkg.version)
+ t.has(o.versions[pkg.version], pkg)
+ t.same(o.maintainers, [ { name: 'username', email: 'i@izs.me' } ])
+ var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ]
+ t.same(att.data, pd)
+ res.statusCode = 409
+ res.json({reason: "must supply latest _rev to update existing package"})
+ })
+ })
+
+ server.expect("/npm-registry-client", function (req, res) {
+ t.equal(req.method, "GET")
+ t.ok(lastTime)
+ for (var i in lastTime.versions) {
+ var v = lastTime.versions[i]
+ delete lastTime.versions[i]
+ lastTime.versions["0.0.2"] = v
+ lastTime["dist-tags"] = { latest: "0.0.2" }
+ }
+ lastTime._rev = "asdf"
+ res.json(lastTime)
+ })
+
+ server.expect("/npm-registry-client", function (req, res) {
+ t.equal(req.method, "PUT")
+ t.ok(lastTime)
+
+ var b = ""
+ req.setEncoding('utf8')
+ req.on("data", function (d) {
+ b += d
+ })
+
+ req.on("end", function() {
+ var o = JSON.parse(b)
+ t.equal(o._rev, "asdf")
+ t.deepEqual(o.versions["0.0.2"], o.versions[pkg.version])
+ res.statusCode = 201
+ res.json({created: true})
+ })
+ })
+
+
+ // not really a tarball, but doesn't matter
+ var tarball = require.resolve('../package.json')
+ var pd = fs.readFileSync(tarball, 'base64')
+ var pkg = require('../package.json')
+ client.publish(pkg, tarball, function (er, data, raw, res) {
+ if (er) throw er
+ t.deepEqual(data, { created: true })
+ t.end()
+ })
+})
diff --git a/deps/npm/node_modules/npm-registry-client/test/publish.js b/deps/npm/node_modules/npm-registry-client/test/publish.js
new file mode 100644
index 000000000..04dac51d1
--- /dev/null
+++ b/deps/npm/node_modules/npm-registry-client/test/publish.js
@@ -0,0 +1,48 @@
+var tap = require('tap')
+var server = require('./fixtures/server.js')
+var RC = require('../')
+var client = new RC(
+ { cache: __dirname + '/fixtures/cache'
+ , registry: 'http://localhost:' + server.port
+ , username: "username"
+ , password: "password"
+ , email: "i@izs.me"
+ , _auth: new Buffer("username:password").toString('base64')
+ , "always-auth": true
+ })
+
+var fs = require("fs")
+
+tap.test("publish", function (t) {
+ server.expect("/npm-registry-client", function (req, res) {
+ t.equal(req.method, "PUT")
+ var b = ""
+ req.setEncoding('utf8')
+ req.on("data", function (d) {
+ b += d
+ })
+
+ req.on("end", function () {
+ var o = JSON.parse(b)
+ console.error('PUT req', o)
+ t.equal(o._id, "npm-registry-client")
+ t.equal(o["dist-tags"].latest, pkg.version)
+ t.has(o.versions[pkg.version], pkg)
+ t.same(o.maintainers, [ { name: 'username', email: 'i@izs.me' } ])
+ var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ]
+ t.same(att.data, pd)
+ res.statusCode = 201
+ res.json({created:true})
+ })
+ })
+
+ // not really a tarball, but doesn't matter
+ var tarball = require.resolve('../package.json')
+ var pd = fs.readFileSync(tarball, 'base64')
+ var pkg = require('../package.json')
+ client.publish(pkg, tarball, function (er, data, raw, res) {
+ if (er) throw er
+ t.deepEqual(data, { created: true })
+ t.end()
+ })
+})