Skip to content

Commit

Permalink
Add delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro committed Feb 15, 2017
1 parent c5382a0 commit 573e506
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions hitit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
hitit - v0.1.1
hitit - v0.1.2
Written by Federico Pereiro (fpereiro@gmail.com) and released into the public domain.
Expand Down Expand Up @@ -38,6 +38,7 @@ Please refer to readme.md to read the annotated source (but not yet!).
['options.headers', o.headers, ['object', 'function', 'undefined'], 'oneOf'],
['options.code', o.code, [undefined, 0, -1].concat (dale.do (http.STATUS_CODES, function (v, k) {return parseInt (k)})), teishi.test.equal, 'oneOf'],
['options.apres', o.apres, ['undefined', 'function'], 'oneOf'],
['options.apres', o.delay, ['undefined', 'integer'], 'oneOf'],
['state', state, 'object'],
]},
['cb', cb, 'function']
Expand Down Expand Up @@ -98,12 +99,14 @@ Please refer to readme.md to read the annotated source (but not yet!).
}

if (rdata.code !== (o.code || 200)) return cb (rdata);
if (o.apres) {
var result = o.apres (state, o, rdata, cb);
if (result === undefined) return;
return result ? cb (null, rdata) : cb (rdata);
}
cb (null, rdata);
setTimeout (function () {
if (o.apres) {
var result = o.apres (state, o, rdata, cb);
if (result === undefined) return;
return result ? cb (null, rdata) : cb (rdata);
}
cb (null, rdata);
}, o.delay || 0);
});

response.on ('error', function (error) {
Expand Down Expand Up @@ -168,7 +171,8 @@ Please refer to readme.md to read the annotated source (but not yet!).
headers: req [3],
body: req [4],
code: req [5],
apres: req [6]
apres: req [6],
delay: req [7]
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hitit",
"version": "0.1.1",
"version": "0.1.2",
"description": "Minimalistic tool for API testing.",
"dependencies": {
"dale": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ hitit is a minimalistic tool for testing an HTTP API.

## Current status of the project

The current version of hitit, v0.1.1, is considered to be *unstable* and *incomplete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are:
The current version of hitit, v0.1.2, is considered to be *unstable* and *incomplete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are:

- Support for `multipart` uploads and downloads.
- Support for concurrent testing (a.k.a stress testing).
Expand Down

0 comments on commit 573e506

Please sign in to comment.