Skip to content

Commit

Permalink
v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro committed Jan 9, 2019
1 parent 474343a commit 32c52e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions hitit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
hitit - v1.2.2
hitit - v1.2.3
Written by Federico Pereiro ([email protected]) and released into the public domain.
*/
Expand Down Expand Up @@ -209,8 +209,10 @@ Written by Federico Pereiro ([email protected]) and released into the public do

preproc (seq);

var t = Date.now ();

var CB = function () {
log ('Starting request', fseq [counter].tag, '(' + (counter + 1) + '/' + fseq.length + ')');
log ('Starting request (' + (Math.round ((Date.now () - t) / 10) / 100) + 's)', fseq [counter].tag, '(' + (counter + 1) + '/' + fseq.length + ')');
h.one (state, fseq [counter++], function (error, rdata) {
if (error) return cb (error, hist);
hist.push (rdata);
Expand All @@ -223,6 +225,7 @@ Written by Federico Pereiro ([email protected]) and released into the public do
}

h.stdmap = function (req) {
if (type (req) !== 'array') return log ('Request passed to h.stdmap must be an array!');
return {
tag: req [0],
method: req [1],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "hitit",
"version": "1.2.2",
"version": "1.2.3",
"description": "Minimalistic tool for API testing.",
"dependencies": {
"dale": "4.3.1",
"dale": "4.3.3",
"mime": "1.6.0",
"teishi": "3.13.0"
"teishi": "3.13.2"
},
"main": "hitit.js",
"author": "Federico Pereiro <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions 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(S) API. It is a stopgap until I

## Current status of the project

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

- Support for concurrent testing (a.k.a stress testing).

Expand Down Expand Up @@ -46,7 +46,7 @@ To do a single request, use `h.one`. This function takes three arguments: `state

Many times it is useful to make a request depending on `state`. For that reason, any of the keys of `options` can also be a function; if so, it will be evaluated passing `state` as its only argument. For example, if `state.id` is `3` and you define `options.path` to be `function (state) {return 'download/' + state.id}`, this is equivalent to setting `options.path` to `'download/3'`. Note that also the matching keys of `state` are evaluated in this way if they are functions.

The `body` can be of any type. If it's `null` or `undefined`, it will be considered an empty string. If it's neither an array or an object, it will be coerced a string. If it is either an array or an object with `body.multipart` being `undefined`, it will be considered a JSON. In this case, it will be automatically stringified and the `content-header` will be set to `application/json` (unless you override this default). Finally, if `body` is an object and `body.multipart` is defined, hitit will do a `multipart/form-data` request. `body.multipart` can be either an object or an array of objects. Each of these objects can represent either a `field` or a `file`. In the case of a `field`, the object will have three keys: `type: 'field'`, `name: STRING` and `value: STRING`. In the case of a `file`, the object will have these fields: `type: 'file'`, `name: STRING`, either `value` or `path` (the first to provide the literal value of the file, the second a path to where the file is) and an optional `contentType` - in its absence, if `path` is provided, a mime lookup of the file will be performed. In my case, I always override this by setting `contentType` to `application/octet-stream`.
The `body` can be of any type. If it's `null` or `undefined`, it will be considered an empty string. If it's neither an array or an object, it will be coerced a string. If it is either an array or an object with `body.multipart` being `undefined`, it will be considered a JSON. In this case, it will be automatically stringified and the `content-header` will be set to `application/json` (unless you override this default). Finally, if `body` is an object and `body.multipart` is defined, hitit will do a `multipart/form-data` request. `body.multipart` can be either an object or an array of objects. Each of these objects can represent either a `field` or a `file`. In the case of a `field`, the object will have three keys: `type: 'field'`, `name: STRING` and `value: STRING`. In the case of a `file`, the object will have these fields: `type: 'file'`, `name: STRING`, either `value` or `path` (the first to provide the literal value of the file, the second a path to where the file is) and an optional `contentType` - in its absence, if `path` is provided, a mime lookup of the file will be performed.

```javascript
// Example
Expand Down

0 comments on commit 32c52e5

Please sign in to comment.