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

feat: file support for harness #720

Merged
merged 6 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions test-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Test text, can be multi line.
====spec====
openapi 2/3 document
====server====
command line arguments to run Prism with
command line arguments to run Prism with. You can use the ${file} template variable
XVincentX marked this conversation as resolved.
Show resolved Hide resolved
====command====
curl command to get the response
====expect====
Expand All @@ -60,7 +60,7 @@ paths:
'application/json':
example: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/json"
====expect====
Expand Down
3 changes: 1 addition & 2 deletions test-harness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ describe('harness', () => {

test(testText, done => {
const [command, ...args] = parsed.command.split(' ').map(t => t.trim());
XVincentX marked this conversation as resolved.
Show resolved Hide resolved
const serverArgs = [...parsed.server.split(' ').map(t => t.trim()), tmpFileHandle.name];

const serverArgs = parsed.server.split(' ').map(t => t.trim().replace('${file}', tmpFileHandle.name));
XVincentX marked this conversation as resolved.
Show resolved Hide resolved
XVincentX marked this conversation as resolved.
Show resolved Hide resolved
prismMockProcessHandle = spawn(path.join(__dirname, '../cli-binaries/prism-cli'), serverArgs);

prismMockProcessHandle.stdout.pipe(split2()).on('data', (line: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
examples:
application/json: "hello"
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ paths:
'application/json':
example: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ paths:
'application/json': "hello"
'application/xml': <project><foo>1</foo><bar>2</bar></project>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json;q=0.8, application/xml"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'application/xml':
example: <project><foo>1</foo><bar>2</bar></project>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json;q=0.8, application/xml"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ paths:
examples:
'text/plain': hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json;q=0.8, application/xml, text/plain;q=0.5"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
'text/plain':
example: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json;q=0.8, application/xml, text/plain;q=0.5"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ paths:
'application/json': hello
'application/vnd.api+json': vendor
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/vnd.api+json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'application/vnd.api+json':
example: vendor
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/vnd.api+json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ paths:
'application/json': hello
'application/vnd.api+json': vendor
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'application/vnd.api+json':
example: vendor
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
application/json:
example: '"abc"'
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ paths:
schema:
type: string
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/check-email -H "Accept: application/json, text/plain, */*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ paths:
schema:
type: string
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/check-email -H "Accept: application/json, text/plain, */*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'application/xml':
example: <project><foo>1</foo><bar>2</bar></project>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/xml, application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ paths:
application/xml: <project><foo>1</foo><bar>2</bar></project>
text/plain: text_plain
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: text/plain, application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
examples:
application/json: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/xml, application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ paths:
'application/json':
example: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/xml, application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ paths:
application/json: "hello"
application/xml: "<project><foo>1</foo><bar>2</bar></project>"
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'application/xml':
example: <project><foo>1</foo><bar>2</bar></project>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: application/*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
examples:
text/plain: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ paths:
'text/plain':
example: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
examples:
'*/*': hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: */*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ paths:
'text/plain':
example: hello
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: */*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'text/plain': hello
'application/json': "hello"
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: */*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ paths:
'application/json':
example: "hello"
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/todos -H "accept: */*"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ paths:
'application/json': hello
'application/xml': <project><foo>1</foo><bar>2</bar></project>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json;q=0.8, application/xml;q=0.9"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
'application/xml':
example: <project><foo>1</foo><bar>2</bar></project>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/todos -H "accept: application/json;q=0.8, application/xml;q=0.9"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ paths:
type: string
example: doggie
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/pet/123
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ definitions:
- pending
- sold
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://127.0.0.1:4010/pets -H 'Accept: application/xml'
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ components:
- pending
- sold
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://127.0.0.1:4010/pets -H 'Accept: application/xml'
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ paths:
examples:
application/xml: <abc>1</abc>
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://127.0.0.1:4010/pets -H "Accept: application/xml"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ paths:
name: Sharik
status: available
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://127.0.0.1:4010/pets -H "Accept: application/xml"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ definitions:
- pending
- sold
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://127.0.0.1:4010/pets -H "Accept: application/xml"
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ paths:
required:
- honey
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X GET http://localhost:4010/honey -H "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"
====expect====
Expand Down
2 changes: 1 addition & 1 deletion test-harness/specs/E2E-Multiple-Refs-Handling.oas3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ components:
type: string
nullable: true
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/
====expect====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ paths:
type: string
example: Kent
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/ -H 'accept: text/plain'
====expect====
Expand Down
2 changes: 1 addition & 1 deletion test-harness/specs/E2E-text-plain-serialisation.oas3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
type: string
example: pong
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i http://localhost:4010/ -H 'accept: text/plain'
====expect====
Expand Down
2 changes: 1 addition & 1 deletion test-harness/specs/allow-empty-value-2.oas2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ paths:
name: id
allowEmptyValue: false
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X POST http://localhost:4010/path -H "Content-Type: application/x-www-form-urlencoded" --data "id"
====expect====
Expand Down
2 changes: 1 addition & 1 deletion test-harness/specs/allow-empty-value.oas2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ paths:
name: id
allowEmptyValue: true
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X POST http://localhost:4010/path -H "Content-Type: application/x-www-form-urlencoded" --data "id"
====expect====
Expand Down
2 changes: 1 addition & 1 deletion test-harness/specs/cors/cors-headers-disabled.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
type: string
example: ok
====server====
mock --cors=false -p 4010
mock --cors=false -p 4010 ${file}
====command====
curl -i -X OPTIONS http://localhost:4010/todos
====expect====
Expand Down
2 changes: 1 addition & 1 deletion test-harness/specs/cors/cors-headers-precedence.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
type: string
example: ok
====server====
mock -p 4010
mock -p 4010 ${file}
====command====
curl -i -X OPTIONS http://localhost:4010/todos
====expect====
Expand Down
Loading