-
-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { test } = require('tap') | ||
const { startServer } = require('./helper') | ||
const autocannon = require('../autocannon') | ||
const aggregateResult = autocannon.aggregateResult | ||
const server = startServer() | ||
const url = 'http://localhost:' + server.address().port | ||
|
||
test('exec separate autocannon instances with skipAggregateResult, then aggregateResult afterwards', async (t) => { | ||
t.plan(2) | ||
|
||
const opts = { | ||
url, | ||
connections: 1, | ||
maxOverallRequests: 10, | ||
skipAggregateResult: true | ||
} | ||
|
||
const results = await Promise.all([ | ||
autocannon(opts), | ||
autocannon(opts) | ||
]) | ||
|
||
const aggregateResults = aggregateResult(results, opts) | ||
|
||
t.equal(aggregateResults['2xx'], 20) | ||
t.equal(aggregateResults.requests.total, 20) | ||
}) | ||
|
||
test('aggregateResult must be passed opts with at least a URL or socketPath property', async (t) => { | ||
t.plan(2) | ||
t.throws(() => aggregateResult([]), 'url or socketPath option required') | ||
t.throws(() => aggregateResult([], {}), 'url or socketPath option required') | ||
}) |