Skip to content

Commit

Permalink
feat: file support for harness
Browse files Browse the repository at this point in the history
  • Loading branch information
XVincentX committed Oct 19, 2019
1 parent 3b0b140 commit b40db35
Show file tree
Hide file tree
Showing 167 changed files with 172 additions and 179 deletions.
2 changes: 1 addition & 1 deletion test-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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());
const serverArgs = [...parsed.server.split(' ').map(t => t.trim()), tmpFileHandle.name];

const serverArgs = parsed.server.split(' ').map(t => t.trim().replace('${file}', tmpFileHandle.name));
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
2 changes: 1 addition & 1 deletion test-harness/specs/cors/cors-headers.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

0 comments on commit b40db35

Please sign in to comment.