Created
January 31, 2012 17:35
-
-
Save kusor/1711761 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = require('tap').test; | |
var uuid = require('node-uuid'); | |
var log4js = require('log4js'); | |
var restify = require('restify'); | |
///--- Globals | |
var PORT = process.env.UNIT_TEST_PORT || 12345; | |
var client; | |
var server; | |
log4js.setGlobalLogLevel('TRACE'); | |
test('setup', function(t) { | |
server = restify.createServer({ | |
log4js: log4js | |
}); | |
t.ok(server); | |
server.del('/hello/:name', function(req, res, next) { | |
res.send(204); | |
return next(); | |
}); | |
server.listen(PORT, '127.0.0.1', function() { | |
t.end(); | |
}); | |
}); | |
test('DELETE /hello/:name', function(t) { | |
client = restify.createClient({ | |
log4js: log4js, | |
url: 'http://127.0.0.1:' + PORT, | |
type: 'json' | |
}); | |
t.ok(client); | |
client.del('/hello/pedro', function(err, req, res, obj) { | |
t.ifError(err); | |
t.ok(req); | |
t.ok(res); | |
t.equal(res.statusCode, 200); | |
t.equal(obj, 204); | |
t.end(); | |
}); | |
}); | |
test('teardown', function(t) { | |
server.close(function() { | |
t.end(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment