1 var test = require('tap').test
3 var server = require('./lib/server.js')
4 var common = require('./lib/common.js')
5 var client = common.freshClient()
9 var URI = 'http://localhost:1337/underscore'
10 var USERNAME = 'username'
11 var PASSWORD = '%1234@asdf%'
12 var EMAIL = 'i@izs.me'
14 var TAG = 'not-lodash'
26 test('tag call contract', function (t) {
27 t.throws(function () {
28 client.tag(undefined, AUTH, nop)
31 t.throws(function () {
32 client.tag([], AUTH, nop)
33 }, 'requires URI to be a string')
35 t.throws(function () {
36 client.tag(URI, undefined, nop)
37 }, 'requires params object')
39 t.throws(function () {
40 client.tag(URI, '', nop)
41 }, 'params must be object')
43 t.throws(function () {
44 client.tag(URI, AUTH, undefined)
45 }, 'requires callback')
47 t.throws(function () {
48 client.tag(URI, AUTH, 'callback')
49 }, 'callback must be function')
53 var params = { tag: TAG, auth: AUTH }
54 client.tag(URI, params, nop)
56 { name: 'AssertionError', message: 'must pass version to tag' },
57 'tag must include version'
62 var params = { version: VERSION, auth: AUTH }
63 client.tag(URI, params, nop)
65 { name: 'AssertionError', message: 'must pass tag name to tag' },
66 'tag must include name'
71 var params = { version: VERSION, tag: TAG }
72 client.tag(URI, params, nop)
74 { name: 'AssertionError', message: 'must pass auth to tag' },
75 'params must include auth'
81 test('tag a package', function (t) {
82 server.expect('PUT', '/underscore/not-lodash', function (req, res) {
83 t.equal(req.method, 'PUT')
86 req.setEncoding('utf8')
87 req.on('data', function (d) {
91 req.on('end', function () {
92 var updated = JSON.parse(b)
94 t.deepEqual(updated, '1.3.2')
97 res.json({ tagged: true })
101 client.tag(URI, PARAMS, function (error, data) {
102 t.ifError(error, 'no errors')
103 t.ok(data.tagged, 'was tagged')