Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status codes to test ID and Dredd output #868

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Documentation of various data structures in both [Gavel.js][] and Dredd. [MSON n

Transaction object is passed as a first argument to [hook functions](hooks.md) and is one of the main public interfaces in Dredd.

- id: `GET /greetings` - identifier for this transaction
- id: `GET (200) /greetings` - identifier for this transaction
- name: `./api-description.apib > My API > Greetings > Hello, world! > Retrieve Message > Example 2` (string) - reference to the transaction definition in the original API description document (see also [Dredd Transactions][])
- origin (object) - reference to the transaction definition in the original API description document (see also [Dredd Transactions][])
- filename: `./api-description.apib` (string)
Expand Down
2 changes: 1 addition & 1 deletion src/transaction-runner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class TransactionRunner

configuredTransaction =
name: transaction.name
id: request.method + ' ' + request.uri
id: request.method + ' (' + expected.statusCode + ') ' + request.uri
host: @parsedUrl.hostname
port: @parsedUrl.port
request: request
Expand Down
2 changes: 1 addition & 1 deletion test/integration/cli/cli-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ describe 'CLI', ->
)

it 'should notify skipping to the stdout', ->
assert.include runtimeInfo.dredd.stdout, 'skip: GET /machines'
assert.include runtimeInfo.dredd.stdout, 'skip: GET (200) /machines'

it 'should hit the only transaction', ->
assert.deepEqual runtimeInfo.server.requestCounts, {'/message': 1}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/dredd-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ describe 'Dredd class Integration', ->
assert.include stderr, 'Fixed transaction name'

describe('when Swagger document has multiple responses', ->
reTransaction = /(\w+): (\w+) \/honey/g
reTransaction = /(\w+): (\w+) \(\d+\) \/honey/g
matches = undefined

beforeEach((done) ->
Expand Down Expand Up @@ -577,7 +577,7 @@ describe 'Dredd class Integration', ->
)

describe('when Swagger document has multiple responses and hooks unskip some of them', ->
reTransaction = /(\w+): (\w+) \/honey/g
reTransaction = /(\w+): (\w+) \(\d+\) \/honey/g
matches = undefined

beforeEach((done) ->
Expand Down
8 changes: 4 additions & 4 deletions test/integration/regressions/regression-319-354-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe 'Regression: Issues #319 and #354', ->

describe 'Attributes defined in resource are referenced from payload [GET /bricks/XYZ42]', ->
it 'fails on missing required property and invalid type', ->
assert.include results.failures[0], 'GET /bricks/XYZ42'
assert.include results.failures[0], 'GET (200) /bricks/XYZ42'
assert.include results.failures[1], 'Missing required property: name'
assert.include results.failures[1], 'Invalid type: number'
it 'has no request body', ->
Expand All @@ -251,7 +251,7 @@ describe 'Regression: Issues #319 and #354', ->

describe 'Attributes defined in resource are referenced from action [POST /bricks]', ->
it 'fails on missing required property and invalid type', ->
assert.include results.failures[2], 'POST /bricks'
assert.include results.failures[2], 'POST (200) /bricks'
assert.include results.failures[3], 'Missing required property: name'
assert.include results.failures[3], 'Invalid type: number'
it 'has correct request body', ->
Expand All @@ -265,7 +265,7 @@ describe 'Regression: Issues #319 and #354', ->

describe 'Attributes defined as data structure are referenced from payload [GET /customers]', ->
it 'fails on invalid type', ->
assert.include results.failures[4], 'GET /customers'
assert.include results.failures[4], 'GET (200) /customers'
assert.include results.failures[5], 'Invalid type: object'
it 'has no request body', ->
assert.isUndefined results.bodies[6]
Expand All @@ -278,7 +278,7 @@ describe 'Regression: Issues #319 and #354', ->

describe 'Attributes defined as data structure are referenced from action [POST /customers]', ->
it 'fails on invalid types', ->
assert.include results.failures[6], 'POST /customers'
assert.include results.failures[6], 'POST (200) /customers'
assert.include results.failures[7], 'Invalid type: null'
assert.include results.failures[7], 'Invalid type: string'
it 'has correct request body', ->
Expand Down
8 changes: 4 additions & 4 deletions test/unit/transaction-runner-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe 'TransactionRunner', ->
it 'should callback with a properly configured transaction', (done) ->
runner.configureTransaction transaction, (err, configuredTransaction) ->
assert.equal configuredTransaction.name, 'Group Machine > Machine > Delete Message > Bogus example name'
assert.equal configuredTransaction.id, 'POST /machines'
assert.equal configuredTransaction.id, 'POST (202) /machines'
assert.isOk configuredTransaction.host
assert.isOk configuredTransaction.request
assert.isOk configuredTransaction.expected
Expand All @@ -337,7 +337,7 @@ describe 'TransactionRunner', ->

it 'should join the endpoint path with transaction uriTemplate together', (done) ->
runner.configureTransaction transaction, (err, configuredTransaction) ->
assert.equal configuredTransaction.id, 'POST /machines'
assert.equal configuredTransaction.id, 'POST (202) /machines'
assert.strictEqual configuredTransaction.host, 'hostname.tld'
assert.equal configuredTransaction.port, 9876
assert.strictEqual configuredTransaction.protocol, 'https:'
Expand All @@ -347,7 +347,7 @@ describe 'TransactionRunner', ->
it 'should keep trailing slash in url if present', (done) ->
transaction.request.uri = '/machines/'
runner.configureTransaction transaction, (err, configuredTransaction) ->
assert.equal configuredTransaction.id, 'POST /machines/'
assert.equal configuredTransaction.id, 'POST (202) /machines/'
assert.strictEqual configuredTransaction.fullPath, '/my/path/to/api' + '/machines/'
done()

Expand All @@ -356,7 +356,7 @@ describe 'TransactionRunner', ->
beforeEach ->
transaction =
name: 'Group Machine > Machine > Delete Message > Bogus example name'
id: 'POST /machines'
id: 'POST (202) /machines'
host: '127.0.0.1'
port: '3000'
request:
Expand Down