-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework example project to use the Kreya example API
- Loading branch information
Showing
52 changed files
with
193 additions
and
201 deletions.
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
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
3 changes: 3 additions & 0 deletions
3
example-project/Kreya features/Scripting/Advanced scripting example-request-0.json
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,3 @@ | ||
{ | ||
"message": "{{ vars.messages ? vars.messages[0] : 'no messages set' }}" | ||
} |
3 changes: 3 additions & 0 deletions
3
example-project/Kreya features/Scripting/Advanced scripting example-request-1.json
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,3 @@ | ||
{ | ||
"message": "{{ vars.messages ? vars.messages[1] : 'no messages set' }}" | ||
} |
3 changes: 3 additions & 0 deletions
3
example-project/Kreya features/Scripting/Advanced scripting example-request-2.json
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,3 @@ | ||
{ | ||
"message": "{{ vars.messages ? vars.messages[2] : 'no messages set' }}" | ||
} |
18 changes: 18 additions & 0 deletions
18
example-project/Kreya features/Scripting/Advanced scripting example.js
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,18 @@ | ||
import { expect } from 'chai'; | ||
|
||
// Code here runs before the request is sent | ||
const messages = ['first message', 'second message', 'third message']; | ||
|
||
// store the messages as a "user variable", which is persisted | ||
kreya.variables.set('messages', messages); | ||
|
||
kreyaGrpc.onResponse(msg => { | ||
kreya.test('Should equal the sent message', () => expect(msg.content.message).to.eql(messages[msg.index])); | ||
}); | ||
|
||
kreyaGrpc.onCallCompleted(call => { | ||
kreya.test('Status should be ok', () => expect(call.status.code).to.equal(0)); | ||
|
||
kreya.trace(`Got ${call.responseCount} responses`); | ||
kreya.test('Response count should match sent messages', () => expect(call.responseCount).to.eql(messages.length)); | ||
}); |
22 changes: 22 additions & 0 deletions
22
example-project/Kreya features/Scripting/Advanced scripting example.krop
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,22 @@ | ||
{ | ||
"details": { | ||
"methodFqn": "kreya.ExampleService.Echo" | ||
}, | ||
"script": { | ||
"src": "Advanced scripting example.js" | ||
}, | ||
"requests": [ | ||
{ | ||
"location": "Advanced scripting example-request-0.json" | ||
}, | ||
{ | ||
"location": "Advanced scripting example-request-1.json" | ||
}, | ||
{ | ||
"location": "Advanced scripting example-request-2.json" | ||
} | ||
], | ||
"operationType": "duplexStreaming", | ||
"invokerName": "grpc", | ||
"importStreamId": "463869a1-4cf8-470d-871d-c873192881c7" | ||
} |
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
2 changes: 1 addition & 1 deletion
2
example-project/Kreya features/Scripting/Scripting gRPC-request.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"greeting": "fooBar" | ||
"name": "fooBar" | ||
} |
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 |
---|---|---|
@@ -1,17 +1,6 @@ | ||
import { expect } from 'chai'; | ||
|
||
let names = []; | ||
|
||
kreyaGrpc.onResponse(msg => { | ||
kreya.test('Size should be ok', () => expect(msg.size).to.be.gt(10)); | ||
kreya.test('Greeting should start with hello', () => expect(msg.content.reply.startsWith('hello')).to.be.true); | ||
|
||
// Store all received names to use them when the gRPC call completes | ||
names.push(msg.content.reply.substr('Hello '.length)); | ||
}); | ||
|
||
kreyaGrpc.onCallCompleted(call => { | ||
kreya.test('Status should be ok', () => expect(call.status.code).to.equal(0)); | ||
|
||
kreya.trace(`Got ${call.responseCount} names: ${names.join(', ')}`); | ||
kreya.test('Message should start with Hello', () => expect(msg.content.message.startsWith('Hello')).to.be.true); | ||
}); |
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,3 @@ | ||
{ | ||
"name": "{{ faker.commerce.product_name }}" | ||
} |
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 was deleted.
Oops, something went wrong.
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,23 @@ | ||
{ | ||
"details": { | ||
"path": "/v1/books/{id}", | ||
"method": "DELETE", | ||
"importedOperationId": "DELETE /v1/books/{id}", | ||
"headers": [], | ||
"pathParams": [ | ||
{ | ||
"key": "id", | ||
"value": "1" | ||
} | ||
] | ||
}, | ||
"requests": [ | ||
{ | ||
"contentType": "none" | ||
} | ||
], | ||
"operationType": "unary", | ||
"invokerName": "rest", | ||
"typeHint": "DELETE", | ||
"importStreamId": "3173a966-56b1-435f-9a60-937058ec6c80" | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
{ | ||
"name": "{{ faker.commerce.product_name }}" | ||
} |
15 changes: 10 additions & 5 deletions
15
example-project/REST/PUT.krop → example-project/REST/Update book.krop
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 |
---|---|---|
@@ -1,24 +1,29 @@ | ||
{ | ||
"details": { | ||
"path": "/anything", | ||
"path": "/v1/books/{id}", | ||
"method": "PUT", | ||
"importedOperationId": "PUT /anything", | ||
"importedOperationId": "PUT /v1/books/{id}", | ||
"headers": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
} | ||
], | ||
"pathParams": [] | ||
"pathParams": [ | ||
{ | ||
"key": "id", | ||
"value": "3" | ||
} | ||
] | ||
}, | ||
"requests": [ | ||
{ | ||
"location": "PUT-request.json", | ||
"location": "Update book-request.json", | ||
"contentType": "json" | ||
} | ||
], | ||
"operationType": "unary", | ||
"invokerName": "rest", | ||
"typeHint": "PUT", | ||
"importStreamId": "cfe3f74c-0483-41e5-85d3-36c85f25e8bb" | ||
"importStreamId": "3173a966-56b1-435f-9a60-937058ec6c80" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.