Skip to content

Commit

Permalink
Minor improvements; bump dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro committed Mar 16, 2018
1 parent 363380b commit 25ee2a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions hitit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
hitit - v1.1.0
hitit - v1.2.0
Written by Federico Pereiro (fpereiro@gmail.com) and released into the public domain.
*/
Expand Down Expand Up @@ -53,7 +53,7 @@ Written by Federico Pereiro (fpereiro@gmail.com) and released into the public do
})
})},
function () {return [
['o.code', o.code, [undefined, 0, -1].concat (dale.do (http.STATUS_CODES, function (v, k) {return parseInt (k)})), teishi.test.equal, 'oneOf'],
['o.code', o.code, ['*', undefined, 0, -1].concat (dale.do (http.STATUS_CODES, function (v, k) {return parseInt (k)})), teishi.test.equal, 'oneOf'],
[o.port !== undefined, ['options.port', o.port, {min: 1, max: 65535}, teishi.test.range]],
[o.method !== undefined, ['options.method', (o.method || '' ).toLowerCase (), ['get', 'head', 'post', 'put', 'delete', 'trace', 'connect', 'patch', 'options'], teishi.test.equal, 'oneOf']],
]},
Expand Down Expand Up @@ -116,7 +116,7 @@ Written by Federico Pereiro (fpereiro@gmail.com) and released into the public do
rdata.body = parsed;
}

if (rdata.code !== (o.code || 200)) return cb (rdata);
if (o.code !== '*' && rdata.code !== (o.code || 200)) return cb (rdata);
setTimeout (function () {
if (o.apres) {
var result = o.apres (state, o, rdata, cb);
Expand Down Expand Up @@ -194,6 +194,7 @@ Written by Federico Pereiro (fpereiro@gmail.com) and released into the public do

var preproc = function (seq) {
dale.do (seq, function (v) {
if (! v || (type (v) === 'array' && v.length === 0)) return;
if (type (v) === 'array' && teishi.complex (v [0])) preproc (v);
else fseq.push (map ? map (v) : v);
});
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "hitit",
"version": "1.1.0",
"version": "1.2.0",
"description": "Minimalistic tool for API testing.",
"dependencies": {
"dale": "4.3.0",
"mime": "1.3.6",
"teishi": "3.11.0"
"dale": "4.3.1",
"mime": "1.6.0",
"teishi": "3.12.0"
},
"main": "hitit.js",
"author": "Federico Pereiro <fpereiro@gmail.com>",
Expand Down
7 changes: 4 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ hitit is a minimalistic tool for testing an HTTP(S) API. It is a stopgap until I

## Current status of the project

The current version of hitit, v1.1.0, is considered to be *somewhat stable* and *somewhat complete*. [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, v1.2.0, is considered to be *somewhat stable* and *somewhat complete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are:

- Allow empty tests.
- Support for concurrent testing (a.k.a stress testing).

## Installation
Expand Down Expand Up @@ -35,7 +34,7 @@ To do a single request, use `h.one`. This function takes three arguments: `state
- `path`: optional string.
- `headers`: optional object.
- `body`: can be of any type. See below for more details.
- `code`: any valid HTTP status code; defaults to 200. If the response has a different matching code, the request will be considered as a failure.
- `code`: any valid HTTP status code; defaults to 200. If the response has a different matching code, the request will be considered as a failure. If you want the request to succeed in any case, you can use `'*'` as the status code.
- `apres`: a function that is executed after the request finishes. See below for more details.
- `delay`: optional integer that determines how many milliseconds should be waited until the next request.
- `timeout`: optional integer that will abort the request after `body.timeout` seconds elapse of socket inactivity. Defaults to `60`.
Expand Down Expand Up @@ -77,6 +76,8 @@ This function accepts a sequence of requests and executes them in turn. It takes

In the simplest case, `sequence` can be an array with a number of objects, each of them a valid `options` object that can be passed to `h.one`. However, you can have nested arrays with `options` inside; `h.seq` will unnest the array for you. This is useful when you have functions returning tests.

If any of the components of `sequence` has a falsy value or is an empty array, it will be ignored. This is useful for creating conditional tests. However, these conditions cannot depend on the dynamic `state` of the test; rather, the conditional must depend on a condition that is defined when `h.seq` is invoked.

Finally, you can use a function for converting each of the elements within `sequence` to a valid `h.one` `options` object. For example, the default `h.stdmap` function converts the following array:

```javascript
Expand Down

0 comments on commit 25ee2a1

Please sign in to comment.