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 TOKEN = 'not-bad-meaning-bad-but-bad-meaning-wombat'
10 var AUTH = { token: TOKEN }
11 var PARAMS = { auth: AUTH }
12 var DEP_USER = 'username'
13 var HOST = 'localhost'
15 test('ping call contract', function (t) {
16 t.throws(function () {
17 client.ping(undefined, AUTH, nop)
20 t.throws(function () {
21 client.ping([], AUTH, nop)
22 }, 'requires URI to be a string')
24 t.throws(function () {
25 client.ping(common.registry, undefined, nop)
26 }, 'requires params object')
28 t.throws(function () {
29 client.ping(common.registry, '', nop)
30 }, 'params must be object')
32 t.throws(function () {
33 client.ping(common.registry, AUTH, undefined)
34 }, 'requires callback')
36 t.throws(function () {
37 client.ping(common.registry, AUTH, 'callback')
38 }, 'callback must be function')
43 client.ping(common.registry, params, nop)
45 { name: 'AssertionError', message: 'must pass auth to ping' },
46 'must pass auth to ping'
52 test('ping', function (t) {
53 server.expect('GET', '/-/ping?write=true', function (req, res) {
54 t.equal(req.method, 'GET')
64 client.ping(common.registry, PARAMS, function (error, found) {
65 t.ifError(error, 'no errors')