Skip to content

Instantly share code, notes, and snippets.

@kusor
Created January 31, 2012 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusor/1711761 to your computer and use it in GitHub Desktop.
Save kusor/1711761 to your computer and use it in GitHub Desktop.
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